summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2007-10-06 16:18:09 +0000
committerTom Lane2007-10-06 16:18:09 +0000
commit1da1c8368750f6fbf44c98581b71f089ab1c5f3f (patch)
treecc991125f3e9daeadabbf993849fe989aca54c67
parent5182996d7bd72c24e90b5cfe20e8b79bc867e397 (diff)
Make dumpcolors() have tolerable performance when using 32-bit chr,
as we do (and upstream Tcl doesn't). The loop limit might be subject to negotiation if anyone ever tries to do regex debugging in Far Eastern languages, but for now 1000 seems plenty. CHR_MAX was right out :-(
-rw-r--r--src/backend/regex/regc_color.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/backend/regex/regc_color.c b/src/backend/regex/regc_color.c
index 4e5a776ee5..3810f53376 100644
--- a/src/backend/regex/regc_color.c
+++ b/src/backend/regex/regc_color.c
@@ -722,13 +722,17 @@ dumpcolors(struct colormap * cm,
else
fprintf(f, "#%2ld%s(%2d): ", (long) co,
has, cd->nchrs);
- /* it's hard to do this more efficiently */
- for (c = CHR_MIN; c < CHR_MAX; c++)
+ /*
+ * Unfortunately, it's hard to do this next bit more efficiently.
+ *
+ * Spencer's original coding has the loop iterating from CHR_MIN
+ * to CHR_MAX, but that's utterly unusable for 32-bit chr.
+ * For debugging purposes it seems fine to print only chr
+ * codes up to 1000 or so.
+ */
+ for (c = CHR_MIN; c < 1000; c++)
if (GETCOLOR(cm, c) == co)
dumpchr(c, f);
- assert(c == CHR_MAX);
- if (GETCOLOR(cm, c) == co)
- dumpchr(c, f);
fprintf(f, "\n");
}
}