From 5f30bd1f0dfa8849e2bffb7181e2686821c77f03 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Mon, 26 Feb 2024 08:46:40 -0800 Subject: [PATCH] Use raw pointers for vectorX configuration instead This is safe as these are from arg[] and sidesteps issues with nullptr. --- CLI/Compile.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/CLI/Compile.cpp b/CLI/Compile.cpp index 06d8bb4c..d3609533 100644 --- a/CLI/Compile.cpp +++ b/CLI/Compile.cpp @@ -46,10 +46,9 @@ struct GlobalOptions int optimizationLevel = 1; int debugLevel = 1; - std::string vectorLib; - std::string vectorCtor; - std::string vectorType; - + const char* vectorLib; + const char* vectorCtor; + const char* vectorType; } globalOptions; static Luau::CompileOptions copts() @@ -58,10 +57,9 @@ static Luau::CompileOptions copts() result.optimizationLevel = globalOptions.optimizationLevel; result.debugLevel = globalOptions.debugLevel; - // globalOptions outlive the CompileOptions, so it's safe to use string data pointers here - result.vectorLib = globalOptions.vectorLib.empty() ? nullptr : globalOptions.vectorLib.c_str(); - result.vectorCtor = globalOptions.vectorCtor.c_str(); - result.vectorType = globalOptions.vectorType.c_str(); + result.vectorLib = globalOptions.vectorLib; + result.vectorCtor = globalOptions.vectorCtor; + result.vectorType = globalOptions.vectorType; return result; }