[PATCH] D81342: [Support] FoldingSetNodeID::AddString(): reserve memory
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 7 09:34:33 PDT 2020
lebedev.ri updated this revision to Diff 269064.
lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.
Use `divideCeil()`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81342/new/
https://reviews.llvm.org/D81342
Files:
llvm/lib/Support/FoldingSet.cpp
Index: llvm/lib/Support/FoldingSet.cpp
===================================================================
--- llvm/lib/Support/FoldingSet.cpp
+++ llvm/lib/Support/FoldingSet.cpp
@@ -86,6 +86,10 @@
void FoldingSetNodeID::AddString(StringRef String) {
unsigned Size = String.size();
+
+ unsigned NumInserts = 1 + divideCeil(Size, 4);
+ Bits.reserve(Bits.size() + NumInserts);
+
Bits.push_back(Size);
if (!Size) return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81342.269064.patch
Type: text/x-patch
Size: 435 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200607/df474ef6/attachment.bin>
More information about the llvm-commits
mailing list