<div dir="ltr">test</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 18, 2013 at 8:21 AM, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi klimek,<br>
<br>
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. Not sure whether this is worth it, or whether we should straight away look into implementing this as a hash map.<br>

<br>
<a href="http://llvm-reviews.chandlerc.com/D418" target="_blank">http://llvm-reviews.chandlerc.com/D418</a><br>
<br>
Files:<br>
  lib/Format/Format.cpp<br>
<br>
Index: lib/Format/Format.cpp<br>
===================================================================<br>
--- lib/Format/Format.cpp<br>
+++ lib/Format/Format.cpp<br>
@@ -676,6 +676,12 @@<br>
   typedef std::priority_queue<QueueItem, std::vector<QueueItem>,<br>
                               std::greater<QueueItem> > QueueType;<br>
<br>
+  struct Compare {<br>
+    bool operator()(LineState *obj1, LineState *obj2) const {<br>
+      return *obj1 < *obj2;<br>
+    }<br>
+  };<br>
+<br>
   /// \brief Analyze the entire solution space starting from \p InitialState.<br>
   ///<br>
   /// This implements a variant of Dijkstra's algorithm on the graph that spans<br>
@@ -683,7 +689,7 @@<br>
   /// find the shortest path (the one with lowest penalty) from \p InitialState<br>
   /// to a state where all tokens are placed.<br>
   unsigned analyzeSolutionSpace(LineState &InitialState) {<br>
-    std::set<LineState> Seen;<br>
+    std::set<LineState *, Compare> Seen;<br>
<br>
     // Insert start element into queue.<br>
     StateNode *Node =<br>
@@ -701,7 +707,7 @@<br>
       }<br>
       Queue.pop();<br>
<br>
-      if (!Seen.insert(Node->State).second)<br>
+      if (!Seen.insert(&Node->State).second)<br>
         // State already examined with lower penalty.<br>
         continue;<br>
</blockquote></div><br></div>