Change StringLiteral to less frequently allocate a new string. (#3314)

Building on #3311, which started moving the result string into a
`unique_ptr`, instead have `StringLiteral` use a `BumpPtrAllocator` to
manage memory. But also, detect when a string is really trivial during
`Lex` and, if so, return `contents_` directly.
This commit is contained in:
Jon Ross-Perkins
2023-10-24 19:15:49 +00:00
committed by GitHub
parent 1d6298290f
commit b2cfd5a8a8
7 changed files with 149 additions and 76 deletions
+2 -1
View File
@@ -33,8 +33,9 @@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
// Check multiline flag was computed correctly.
CARBON_CHECK(token->is_multi_line() == token->text().contains('\n'));
llvm::BumpPtrAllocator allocator;
volatile auto value =
token->ComputeValue(NullDiagnosticEmitter<const char*>());
token->ComputeValue(allocator, NullDiagnosticEmitter<const char*>());
(void)value;
return 0;