Use raw pointers for vectorX configuration instead

This is safe as these are from arg[] and sidesteps issues with nullptr.
This commit is contained in:
Arseny Kapoulkine 2024-02-26 08:46:40 -08:00
parent 233072f045
commit 5f30bd1f0d

View file

@ -46,10 +46,9 @@ struct GlobalOptions
int optimizationLevel = 1; int optimizationLevel = 1;
int debugLevel = 1; int debugLevel = 1;
std::string vectorLib; const char* vectorLib;
std::string vectorCtor; const char* vectorCtor;
std::string vectorType; const char* vectorType;
} globalOptions; } globalOptions;
static Luau::CompileOptions copts() static Luau::CompileOptions copts()
@ -58,10 +57,9 @@ static Luau::CompileOptions copts()
result.optimizationLevel = globalOptions.optimizationLevel; result.optimizationLevel = globalOptions.optimizationLevel;
result.debugLevel = globalOptions.debugLevel; result.debugLevel = globalOptions.debugLevel;
// globalOptions outlive the CompileOptions, so it's safe to use string data pointers here result.vectorLib = globalOptions.vectorLib;
result.vectorLib = globalOptions.vectorLib.empty() ? nullptr : globalOptions.vectorLib.c_str(); result.vectorCtor = globalOptions.vectorCtor;
result.vectorCtor = globalOptions.vectorCtor.c_str(); result.vectorType = globalOptions.vectorType;
result.vectorType = globalOptions.vectorType.c_str();
return result; return result;
} }