Skip to content

Commit c48a8fa

Browse files
committed
refactor(diag): rename Lexer::allocator_ for clarity
Make it clear that Lexer::allocator_ is only used for diagnostic-related allocations by naming it diag_memory_.
1 parent cd32967 commit c48a8fa

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/quick-lint-js/fe/lex.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ Lexer::Parsed_Template_Body Lexer::parse_template_body(
985985
case 'u': {
986986
if (!escape_sequence_diagnostics) {
987987
escape_sequence_diagnostics =
988-
this->allocator_.new_object<Diag_List>(&this->allocator_);
988+
this->diag_memory_.new_object<Diag_List>(&this->diag_memory_);
989989
}
990990
c = this->parse_unicode_escape(escape_sequence_start,
991991
escape_sequence_diagnostics)
@@ -1474,7 +1474,7 @@ void Lexer::check_integer_precision_loss(String8_View number_literal) {
14741474
if (cleaned_string != result_string_view) {
14751475
// TODO(strager): Use Linked_Bump_Allocator::new_objects_copy
14761476
Span<Char8> rounded_val =
1477-
this->allocator_.allocate_uninitialized_span<Char8>(
1477+
this->diag_memory_.allocate_uninitialized_span<Char8>(
14781478
result_string_view.size());
14791479
std::uninitialized_copy(result_string_view.begin(),
14801480
result_string_view.end(), rounded_val.data());
@@ -1809,12 +1809,12 @@ Lexer::Parsed_Identifier Lexer::parse_identifier_slow(
18091809
is_private_identifier ? &identifier_begin[-1] : identifier_begin;
18101810

18111811
Vector<Char8> normalized("parse_identifier_slow normalized",
1812-
&this->allocator_);
1812+
&this->diag_memory_);
18131813
normalized.append(private_identifier_begin, input);
18141814

18151815
Escape_Sequence_List* escape_sequences =
1816-
this->allocator_.new_object<Escape_Sequence_List>(
1817-
"parse_identifier_slow escape_sequences", &this->allocator_);
1816+
this->diag_memory_.new_object<Escape_Sequence_List>(
1817+
"parse_identifier_slow escape_sequences", &this->diag_memory_);
18181818

18191819
auto parse_unicode_escape = [&]() {
18201820
const Char8* escape_begin = input;

src/quick-lint-js/fe/lex.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,11 @@ class Lexer {
341341
Padded_String_View original_input_;
342342
Lexer_Options options_;
343343

344-
Monotonic_Allocator allocator_{"lexer::allocator_"};
344+
// Allocator for diagnostic-related memory, including Diag_List and temporary
345+
// strings.
346+
Monotonic_Allocator diag_memory_{"Lexer::diag_memory_"};
345347

346-
Diag_List diags_ = Diag_List(&this->allocator_);
348+
Diag_List diags_ = Diag_List(&this->diag_memory_);
347349

348350
friend struct Lex_Tables;
349351
};

0 commit comments

Comments
 (0)