Rework Pointer::operator<() loop.

I must be too dumb to understand the mess MSVC (32bit only) did with the
previous loop, and to figure out how it might have make it never end.
Anyway, hopefully any compiler can grok this new loop...
diff --git a/include/rapidjson/pointer.h b/include/rapidjson/pointer.h
index 54a8c9a..97a376a 100644
--- a/include/rapidjson/pointer.h
+++ b/include/rapidjson/pointer.h
@@ -358,7 +358,7 @@
 
     //! Less than operator.
     /*!
-        \note Invalid pointers are never lesser than valid ones.
+        \note Invalid pointers are always greater than valid ones.
     */
     bool operator<(const GenericPointer& rhs) const {
         if (!IsValid())
@@ -366,27 +366,20 @@
         if (!rhs.IsValid())
             return true;
 
-        size_t i = 0, lCount = tokenCount_, rCount = rhs.tokenCount_;
-        for (;;) {
-            if (!rCount)
-                return false;
-            if (!lCount)
-                return true;
+        const Token *lTok = tokens_, *const lEnd = lTok + tokenCount_,
+                    *rTok = rhs.tokens_, *const rEnd = rTok + rhs.tokenCount_;
+        for (; lTok != lEnd && rTok != rEnd; ++lTok, ++rTok) {
+            if (lTok->index != rTok->index)
+                return lTok->index < rTok->index;
 
-            if (tokens_[i].index != rhs.tokens_[i].index)
-                return tokens_[i].index < rhs.tokens_[i].index;
+            if (lTok->length > rTok->length)
+                return std::memcmp(lTok->name, rTok->name, sizeof(Ch) * rTok->length) < 0;
 
-            if (tokens_[i].length > rhs.tokens_[i].length)
-                return std::memcmp(tokens_[i].name, rhs.tokens_[i].name, sizeof(Ch) * rhs.tokens_[i].length) < 0;
-
-            int cmp = std::memcmp(tokens_[i].name, rhs.tokens_[i].name, sizeof(Ch) * tokens_[i].length);
-            if (cmp || tokens_[i].length != rhs.tokens_[i].length)
-                return cmp <= 0;
-
-            lCount--;
-            rCount--;
-            i++;
+            int comp = std::memcmp(lTok->name, rTok->name, sizeof(Ch) * lTok->length);
+            if (comp || lTok->length != rTok->length)
+                return comp <= 0;
         }
+        return rTok != rEnd;
     }
 
     //@}
diff --git a/test/unittest/pointertest.cpp b/test/unittest/pointertest.cpp
index 401bf7d..8d6f187 100644
--- a/test/unittest/pointertest.cpp
+++ b/test/unittest/pointertest.cpp
@@ -1515,8 +1515,8 @@
         "/e/f.g",
         ""
     };
-    static struct {
-        const char *string;
+    static const struct {
+        const char *str;
         bool valid;
     } ordered_pointers[] = {
         { "", true },
@@ -1537,24 +1537,29 @@
         { "/e/f~g", false },
         { "/e/f~~g", false }
     };
-    MemoryPoolAllocator<> allocator;
-    typedef GenericPointer<Value, MemoryPoolAllocator<> > PooledPointer;
-    std::multiset<PooledPointer> set;
+    typedef MemoryPoolAllocator<> AllocatorType;
+    typedef GenericPointer<Value, AllocatorType> PointerType;
+    typedef std::multiset<PointerType> PointerSet;
+    AllocatorType allocator;
+    PointerSet set;
     size_t i;
 
-    for (i = 0; i < sizeof(pointers) / sizeof(*pointers); ++i) {
-        set.insert(PooledPointer(pointers[i], &allocator));
+    EXPECT_EQ(sizeof(pointers) / sizeof(pointers[0]),
+              sizeof(ordered_pointers) / sizeof(ordered_pointers[0]));
+
+    for (i = 0; i < sizeof(pointers) / sizeof(pointers[0]); ++i) {
+        set.insert(PointerType(pointers[i], &allocator));
     }
 
     i = 0;
-    for (std::set<PooledPointer>::iterator it = set.begin(); it != set.end(); ++it) {
-        EXPECT_TRUE(i < sizeof(ordered_pointers) / sizeof(*ordered_pointers));
+    for (PointerSet::iterator it = set.begin(); it != set.end(); ++it) {
+        EXPECT_TRUE(i < sizeof(ordered_pointers) / sizeof(ordered_pointers[0]));
         EXPECT_EQ(it->IsValid(), ordered_pointers[i].valid);
         if (it->IsValid()) {
             std::stringstream ss;
             OStreamWrapper os(ss);
             EXPECT_TRUE(it->Stringify(os));
-            EXPECT_EQ(ss.str(), ordered_pointers[i].string);
+            EXPECT_EQ(ss.str(), ordered_pointers[i].str);
         }
         i++;
     }