Don't inline the larger functions.

Change-Id: I9cd75d9301c77b1bc1866d32b46915e91548cba6
Reviewed-on: https://code-review.googlesource.com/5243
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/re2/prog.cc b/re2/prog.cc
index ccdd568..aa7e8e2 100644
--- a/re2/prog.cc
+++ b/re2/prog.cc
@@ -317,72 +317,15 @@
 class ByteMapBuilder {
  public:
   ByteMapBuilder() {
-    // This allows the outer loop in Build() to be simple.
     subranges_.Set(255);
   }
 
   // Marks the [lo, hi] subrange.
-  void Mark(int lo, int hi) {
-    DCHECK_GE(lo, 0);
-    DCHECK_GE(hi, 0);
-    DCHECK_LE(lo, 255);
-    DCHECK_LE(hi, 255);
-    DCHECK_LE(lo, hi);
-
-    if (lo == 0 && hi == 255)
-      return;
-
-    // We track the end of each subrange. We also track which subranges
-    // are "present" (i.e. were marked) so that the remaining, "absent"
-    // subranges can subsequently be made to share a single byte class.
-    lo--;
-    if (0 <= lo && !subranges_.Test(lo)) {
-      subranges_.Set(lo);
-      int next = subranges_.FindNextSetBit(lo+1);
-      if (present_.Test(next))
-        present_.Set(lo);
-    }
-    if (!subranges_.Test(hi))
-      subranges_.Set(hi);
-    // Flag as "present" the subranges above lo up to and including the
-    // subrange ending at hi.
-    int c = lo+1;
-    while (c < 256) {
-      int next = subranges_.FindNextSetBit(c);
-      if (!present_.Test(next))
-        present_.Set(next);
-      if (next == hi)
-        break;
-      c = next+1;
-    }
-  }
+  void Mark(int lo, int hi);
 
   // Builds the bytemap from the subranges.
   // Returns the number of byte classes.
-  int Build(uint8* bytemap) {
-    int present = 0;
-    int absent = -1;
-    int c = 0;
-    while (c < 256) {
-      int next = subranges_.FindNextSetBit(c);
-      uint8 b = 0;
-      if (present_.Test(next)) {
-        b = static_cast<uint8>(present);
-        present++;
-      } else {
-        if (absent == -1) {
-          absent = present;
-          present++;
-        }
-        b = static_cast<uint8>(absent);
-      }
-      while (c <= next) {
-        bytemap[c] = b;
-        c++;
-      }
-    }
-    return present;
-  }
+  int Build(uint8* bytemap);
 
  private:
   Bitmap256 subranges_;
@@ -391,10 +334,70 @@
   DISALLOW_COPY_AND_ASSIGN(ByteMapBuilder);
 };
 
+void ByteMapBuilder::Mark(int lo, int hi) {
+  DCHECK_GE(lo, 0);
+  DCHECK_GE(hi, 0);
+  DCHECK_LE(lo, 255);
+  DCHECK_LE(hi, 255);
+  DCHECK_LE(lo, hi);
+
+  if (lo == 0 && hi == 255)
+    return;
+
+  // We track the end of each subrange. We also track which subranges
+  // are "present" (i.e. were marked) so that the remaining, "absent"
+  // subranges can subsequently be made to share a single byte class.
+  lo--;
+  if (0 <= lo && !subranges_.Test(lo)) {
+    subranges_.Set(lo);
+    int next = subranges_.FindNextSetBit(lo+1);
+    if (present_.Test(next))
+      present_.Set(lo);
+  }
+  if (!subranges_.Test(hi))
+    subranges_.Set(hi);
+  // Flag as "present" the subranges above lo up to and including the
+  // subrange ending at hi.
+  int c = lo+1;
+  while (c < 256) {
+    int next = subranges_.FindNextSetBit(c);
+    if (!present_.Test(next))
+      present_.Set(next);
+    if (next == hi)
+      break;
+    c = next+1;
+  }
+}
+
+int ByteMapBuilder::Build(uint8* bytemap) {
+  int present = 0;
+  int absent = -1;
+  int c = 0;
+  while (c < 256) {
+    int next = subranges_.FindNextSetBit(c);
+    uint8 b = 0;
+    if (present_.Test(next)) {
+      b = static_cast<uint8>(present);
+      present++;
+    } else {
+      if (absent == -1) {
+        absent = present;
+        present++;
+      }
+      b = static_cast<uint8>(absent);
+    }
+    while (c <= next) {
+      bytemap[c] = b;
+      c++;
+    }
+  }
+  return present;
+}
+
 void Prog::ComputeByteMap() {
   // Fill in byte map with byte classes for the program.
   // Ranges of bytes that are treated indistinguishably
-  // are mapped to a single byte class.
+  // will be mapped to a single byte class.
   ByteMapBuilder builder;
 
   // Don't repeat the work for ^ and $.
diff --git a/util/bitmap.h b/util/bitmap.h
index 91519e6..1e6a2e7 100644
--- a/util/bitmap.h
+++ b/util/bitmap.h
@@ -36,33 +36,7 @@
 
   // Finds the next non-zero bit with index >= c.
   // Returns -1 if no such bit exists.
-  int FindNextSetBit(int c) const {
-    DCHECK_GE(c, 0);
-    DCHECK_LE(c, 255);
-
-    // Mask out any lower bits.
-    int i = c / 64;
-    uint64 word = words_[i] & (~0ULL << (c % 64));
-    if (word != 0)
-      return (i * 64) + FindLSBSet(word);
-    i++;
-    switch (i) {
-      case 1:
-        if (words_[1] != 0)
-          return (1 * 64) + FindLSBSet(words_[1]);
-        // Fall through.
-      case 2:
-        if (words_[2] != 0)
-          return (2 * 64) + FindLSBSet(words_[2]);
-        // Fall through.
-      case 3:
-        if (words_[3] != 0)
-          return (3 * 64) + FindLSBSet(words_[3]);
-        // Fall through.
-      default:
-        return -1;
-    }
-  }
+  int FindNextSetBit(int c) const;
 
  private:
   // Finds the least significant non-zero bit in n.
@@ -83,6 +57,36 @@
   uint64 words_[4];
 };
 
+int Bitmap256::FindNextSetBit(int c) const {
+  DCHECK_GE(c, 0);
+  DCHECK_LE(c, 255);
+
+  // Check the word that contains the bit. Mask out any lower bits.
+  int i = c / 64;
+  uint64 word = words_[i] & (~0ULL << (c % 64));
+  if (word != 0)
+    return (i * 64) + FindLSBSet(word);
+
+  // Check any following words.
+  i++;
+  switch (i) {
+    case 1:
+      if (words_[1] != 0)
+        return (1 * 64) + FindLSBSet(words_[1]);
+      // Fall through.
+    case 2:
+      if (words_[2] != 0)
+        return (2 * 64) + FindLSBSet(words_[2]);
+      // Fall through.
+    case 3:
+      if (words_[3] != 0)
+        return (3 * 64) + FindLSBSet(words_[3]);
+      // Fall through.
+    default:
+      return -1;
+  }
+}
+
 }  // namespace re2
 
 #endif  // RE2_UTIL_BITMAP_H__