Move the bytemap dump code into Prog::DumpByteMap().
Change-Id: I5f23ce1fa7d190917f94b8196cac458e7ec26fbd
Reviewed-on: https://code-review.googlesource.com/4763
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/re2/prog.cc b/re2/prog.cc
index 7ce663c..9fcf418 100644
--- a/re2/prog.cc
+++ b/re2/prog.cc
@@ -149,26 +149,12 @@
}
string Prog::Dump() {
- string map;
- if (false) { // Debugging
- StringAppendF(&map, "byte map:\n");
- for (int c = 0; c < 256; c++) {
- int b = bytemap_[c];
- int lo = c;
- while (c < 256-1 && bytemap_[c+1] == b)
- c++;
- int hi = c;
- StringAppendF(&map, "\t[%02x-%02x] -> %d\n", lo, hi, b);
- }
- StringAppendF(&map, "\n");
- }
-
if (did_flatten_)
- return map + FlattenedProgToString(this, start_);
+ return FlattenedProgToString(this, start_);
Workq q(size_);
AddToQueue(&q, start_);
- return map + ProgToString(this, &q);
+ return ProgToString(this, &q);
}
string Prog::DumpUnanchored() {
@@ -180,6 +166,19 @@
return ProgToString(this, &q);
}
+string Prog::DumpByteMap() {
+ string map;
+ for (int c = 0; c < 256; c++) {
+ int b = bytemap_[c];
+ int lo = c;
+ while (c < 256-1 && bytemap_[c+1] == b)
+ c++;
+ int hi = c;
+ StringAppendF(&map, "[%02x-%02x] -> %d\n", lo, hi, b);
+ }
+ return map;
+}
+
static bool IsMatch(Prog*, Prog::Inst*);
// Peep-hole optimizer.
diff --git a/re2/prog.h b/re2/prog.h
index 895e55e..ee2093d 100644
--- a/re2/prog.h
+++ b/re2/prog.h
@@ -233,6 +233,7 @@
// Returns string representation of program for debugging.
string Dump();
string DumpUnanchored();
+ string DumpByteMap();
// Record that at some point in the prog, the bytes in the range
// lo-hi (inclusive) are treated as different from bytes outside the range.