[PATCH] D142574: [llvm] Replace array allocation pattern by SmallVector in ComputeMappedEditDistance
serge via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 25 22:59:54 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ab51fff3c2a: [llvm] Replace array allocation pattern by SmallVector in… (authored by serge-sans-paille).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142574/new/
https://reviews.llvm.org/D142574
Files:
llvm/include/llvm/ADT/edit_distance.h
Index: llvm/include/llvm/ADT/edit_distance.h
===================================================================
--- llvm/include/llvm/ADT/edit_distance.h
+++ llvm/include/llvm/ADT/edit_distance.h
@@ -18,7 +18,6 @@
#include "llvm/ADT/ArrayRef.h"
#include <algorithm>
-#include <memory>
namespace llvm {
@@ -70,16 +69,8 @@
return MaxEditDistance + 1;
}
- const unsigned SmallBufferSize = 64;
- unsigned SmallBuffer[SmallBufferSize];
- std::unique_ptr<unsigned[]> Allocated;
- unsigned *Row = SmallBuffer;
- if (n + 1 > SmallBufferSize) {
- Row = new unsigned[n + 1];
- Allocated.reset(Row);
- }
-
- for (unsigned i = 1; i <= n; ++i)
+ SmallVector<unsigned, 64> Row(n + 1);
+ for (unsigned i = 1; i < Row.size(); ++i)
Row[i] = i;
for (typename ArrayRef<T>::size_type y = 1; y <= m; ++y) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142574.492341.patch
Type: text/x-patch
Size: 833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230126/5b80bac9/attachment.bin>
More information about the llvm-commits
mailing list