From: Tom Lane Date: Sat, 6 Oct 2007 16:18:09 +0000 (+0000) Subject: Make dumpcolors() have tolerable performance when using 32-bit chr, X-Git-Tag: REL8_3_BETA2~125 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=298c4575200e25d1e1c3447b5400e1a6f91bc500;p=postgresql 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 :-( --- diff --git a/src/backend/regex/regc_color.c b/src/backend/regex/regc_color.c index 33a6c79206..0264760ea7 100644 --- a/src/backend/regex/regc_color.c +++ b/src/backend/regex/regc_color.c @@ -28,7 +28,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/backend/regex/regc_color.c,v 1.5 2005/10/15 02:49:24 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/regex/regc_color.c,v 1.6 2007/10/06 16:18:09 tgl Exp $ * * * Note that there are some incestuous relationships between this code and @@ -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"); } }