Skip to content

Commit 0230277

Browse files
committed
[llvm][mustache] Avoid redundant saves in accessor splitting
The splitMustacheString function was saving StringRefs that were already backed by an arena-allocated string. This was unnecessary work. This change removes the redundant Ctx.Saver.save() call. This optimization provides a small but measurable performance improvement on top of the single-pass tokenizer, most notably reducing branch misses. Metric | Baseline | Optimized | Change -------------- | -------- | --------- | ------- Time (ms) | 35.77 | 35.57 | -0.56% Cycles | 35.16M | 34.91M | -0.71% Instructions | 85.77M | 85.54M | -0.27% Branch Misses | 113.9K | 111.9K | -1.76% Cache Misses | 237.7K | 242.1K | +1.85%
1 parent fbaaa82 commit 0230277

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Support/Mustache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static Accessor splitMustacheString(StringRef Str, MustacheContext &Ctx) {
5151
std::tie(Part, Str) = Str.split('.');
5252
// Each part of the accessor needs to be saved to the arena
5353
// to ensure it has a stable address.
54-
Tokens.push_back(Ctx.Saver.save(Part.trim()));
54+
Tokens.push_back(Part.trim());
5555
}
5656
}
5757
// Now, allocate memory for the array of StringRefs in the arena.

0 commit comments

Comments
 (0)