1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 05:39:42 +00:00

Use string_view in register methods

This commit is contained in:
Evil Eye 2024-06-29 15:37:13 +02:00
parent ad7fb3d13f
commit 1cea604257
2 changed files with 10 additions and 9 deletions

View file

@ -51,11 +51,11 @@ namespace Compiler
}
void Extensions::registerFunction(
const std::string& keyword, ScriptReturn returnType, ScriptArgs argumentType, int code, int codeExplicit)
std::string_view keyword, ScriptReturn returnType, std::string_view argumentType, int code, int codeExplicit)
{
Function function;
if (argumentType.find('/') == std::string::npos)
if (argumentType.find('/') == std::string_view::npos)
{
function.mSegment = 5;
assert(code >= 33554432 && code <= 67108863);
@ -73,7 +73,7 @@ namespace Compiler
mKeywords.emplace(keyword, keywordIndex);
function.mReturn = returnType;
function.mArguments = std::move(argumentType);
function.mArguments = argumentType;
function.mCode = code;
function.mCodeExplicit = codeExplicit;
@ -81,11 +81,11 @@ namespace Compiler
}
void Extensions::registerInstruction(
const std::string& keyword, ScriptArgs argumentType, int code, int codeExplicit)
std::string_view keyword, std::string_view argumentType, int code, int codeExplicit)
{
Instruction instruction;
if (argumentType.find('/') == std::string::npos)
if (argumentType.find('/') == std::string_view::npos)
{
instruction.mSegment = 5;
assert(code >= 33554432 && code <= 67108863);
@ -102,7 +102,7 @@ namespace Compiler
mKeywords.emplace(keyword, keywordIndex);
instruction.mArguments = std::move(argumentType);
instruction.mArguments = argumentType;
instruction.mCode = code;
instruction.mCodeExplicit = codeExplicit;

View file

@ -80,15 +80,16 @@ namespace Compiler
/// \param explicitReference In: has explicit reference; Out: set to false, if
/// explicit reference is not available for this instruction.
void registerFunction(const std::string& keyword, ScriptReturn returnType, ScriptArgs argumentType, int code,
int codeExplicit = -1);
void registerFunction(std::string_view keyword, ScriptReturn returnType, std::string_view argumentType,
int code, int codeExplicit = -1);
///< Register a custom function
/// - keyword must be all lower case.
/// - keyword must be unique
/// - if explicit references are not supported, segment5codeExplicit must be set to -1
/// \note Currently only segment 3 and segment 5 opcodes are supported.
void registerInstruction(const std::string& keyword, ScriptArgs argumentType, int code, int codeExplicit = -1);
void registerInstruction(
std::string_view keyword, std::string_view argumentType, int code, int codeExplicit = -1);
///< Register a custom instruction
/// - keyword must be all lower case.
/// - keyword must be unique