[all-commits] [llvm/llvm-project] efcb07: [llvm][Support] Avoid intermediate heap allocation...
Jan Svoboda via All-commits
all-commits at lists.llvm.org
Thu Aug 3 11:12:21 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: efcb07bf6e5fb0ff12e5855ab0ad86cd534d5578
https://github.com/llvm/llvm-project/commit/efcb07bf6e5fb0ff12e5855ab0ad86cd534d5578
Author: Jan Svoboda <jan_svoboda at apple.com>
Date: 2023-08-03 (Thu, 03 Aug 2023)
Changed paths:
M llvm/include/llvm/Support/StringSaver.h
M llvm/lib/Support/StringSaver.cpp
Log Message:
-----------
[llvm][Support] Avoid intermediate heap allocations in `StringSaver`
The `Twine::str()` function currently always allocates heap memory via `std::string`. However, some instances of `Twine` don't need an intermediate buffer at all, and the rest can attempt to print into a stack buffer first.
This is intentionally not making use of `Twine::isSingleStringLiteral()` from D157010 to skip saving the string in the bump-pointer allocator, since the `StringSaver` documentation suggests that MUST happen for every given string.
Reviewed By: benlangmuir
Differential Revision: https://reviews.llvm.org/D157015
More information about the All-commits
mailing list