[llvm] [llvm-strings] Use small buffer instead of reading whole file (PR #163073)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 12 23:36:12 PDT 2026
================
@@ -110,19 +113,37 @@ static void strings(raw_ostream &OS, StringRef FileName, StringRef Contents) {
OS << L << '\n';
};
- const char *B = Contents.begin();
- const char *P = nullptr, *E = nullptr, *S = nullptr;
- for (P = Contents.begin(), E = Contents.end(); P < E; ++P) {
- if (isPrint(*P) || *P == '\t') {
- if (S == nullptr)
- S = P;
- } else if (S) {
- print(S - B, StringRef(S, P - S));
- S = nullptr;
+ Buffer.resize_for_overwrite(sys::fs::DefaultReadChunkSize);
+ std::string StringBuffer;
----------------
aokblast wrote:
I think it increases the runtime in some cases as it adds some branch to test the buffer. But I switch in accordance with your suggestion now.
https://github.com/llvm/llvm-project/pull/163073
More information about the llvm-commits
mailing list