diff options
| author | Daniel Jasper <djasper@google.com> | 2014-05-22 11:47:01 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-05-22 11:47:01 +0000 |
| commit | 0ae1b95f2fb62c33185dc25a93087b90f407ada8 (patch) | |
| tree | 0b3a75ce697490f76cb2ee8d22a488692776339a /lib/Format/Format.cpp | |
| parent | fc95a27fee8883d9dd403fdb46524fb95fb31f58 (diff) | |
| download | clang-0ae1b95f2fb62c33185dc25a93087b90f407ada8.tar.gz clang-0ae1b95f2fb62c33185dc25a93087b90f407ada8.tar.bz2 clang-0ae1b95f2fb62c33185dc25a93087b90f407ada8.tar.xz | |
clang-format: Store pointers to seen formatting states.
As the memory ownership is handled by the SpecificBumpPtrAllocator
anyway, there is no need to duplicate states when inserting them into
the Seen-set. This leads to an improvement of ~10% on the benchmark
formatting file.
No functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
| -rw-r--r-- | lib/Format/Format.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 471af1d539..2821e4aa2c 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1005,6 +1005,12 @@ private: return Style.ColumnLimit - (InPPDirective ? 2 : 0); } + struct CompareLineStatePointers { + bool operator()(LineState *obj1, LineState *obj2) const { + return *obj1 < *obj2; + } + }; + /// \brief Analyze the entire solution space starting from \p InitialState. /// /// This implements a variant of Dijkstra's algorithm on the graph that spans @@ -1014,7 +1020,7 @@ private: /// /// If \p DryRun is \c false, directly applies the changes. unsigned analyzeSolutionSpace(LineState &InitialState, bool DryRun = false) { - std::set<LineState> Seen; + std::set<LineState *, CompareLineStatePointers> Seen; // Increasing count of \c StateNode items we have created. This is used to // create a deterministic order independent of the container. @@ -1044,7 +1050,7 @@ private: if (Count > 10000) Node->State.IgnoreStackForComparison = true; - if (!Seen.insert(Node->State).second) + if (!Seen.insert(&Node->State).second) // State already examined with lower penalty. continue; |
