While doing some review of the LIKE function, I noticed some useless
bits left over from the pre-MB and converting-MB world.  These are
close to no ops, but it removes at least one function call from every
row processed by the LIKE operator, and it seemed like a slight clean
up of some #defines, which helped reduce some clutter.  If someone'd
like, I can clean this up so it's not doing a #include of a .c file,
which seemed a bit hoakey, but with least resistance as the goal, this
patch should stand alone and as it is: all regression tests pass. -sc

-- 
Sean Chittenden
Index: like.c
===================================================================
RCS file: /home/ncvs/pgsql/pgsql-server/src/backend/utils/adt/like.c,v
retrieving revision 1.53
diff -u -r1.53 like.c
--- like.c      3 Sep 2002 21:45:42 -0000       1.53
+++ like.c      23 Jun 2003 06:19:01 -0000
@@ -36,11 +36,6 @@
                   unsigned char *p, int plen);
 static text *do_like_escape(text *, text *);
 
-static int MBMatchText(unsigned char *t, int tlen,
-                       unsigned char *p, int plen);
-static int MBMatchTextIC(unsigned char *t, int tlen,
-                         unsigned char *p, int plen);
-static text *MB_do_like_escape(text *, text *);
 
 /*--------------------
  * Support routine for MatchText. Compares given multibyte streams
@@ -116,17 +111,11 @@
                         *(dst)++ = *(src)++; \
           } while (0)
 
-#define MatchText      MBMatchText
-#define MatchTextIC MBMatchTextIC
-#define do_like_escape MB_do_like_escape
 #include "like_match.c"
 #undef CHAREQ
 #undef ICHAREQ
 #undef NextChar
 #undef CopyAdvChar
-#undef MatchText
-#undef MatchTextIC
-#undef do_like_escape
 
 #define CHAREQ(p1, p2) (*(p1) == *(p2))
 #define ICHAREQ(p1, p2) (tolower(*(p1)) == tolower(*(p2)))
@@ -136,7 +125,6 @@
 #define BYTEA_CHAREQ(p1, p2) (*(p1) == *(p2))
 #define BYTEA_NextChar(p, plen) ((p)++, (plen)--)
 #define BYTEA_CopyAdvChar(dst, src, srclen) (*(dst)++ = *(src)++, (srclen)--)
-#include "like_match.c"
 
 /*
  *     interface routines called by the function manager
@@ -158,10 +146,7 @@
        p = VARDATA(pat);
        plen = (VARSIZE(pat) - VARHDRSZ);
 
-       if (pg_database_encoding_max_length() == 1)
-               result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
-       else
-               result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
+       result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
 
        PG_RETURN_BOOL(result);
 }
@@ -182,10 +167,7 @@
        p = VARDATA(pat);
        plen = (VARSIZE(pat) - VARHDRSZ);
 
-       if (pg_database_encoding_max_length() == 1)
-               result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
-       else
-               result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
+       result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
 
        PG_RETURN_BOOL(result);
 }
@@ -206,10 +188,7 @@
        p = VARDATA(pat);
        plen = (VARSIZE(pat) - VARHDRSZ);
 
-       if (pg_database_encoding_max_length() == 1)
-               result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
-       else
-               result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
+       result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
 
        PG_RETURN_BOOL(result);
 }
@@ -230,10 +209,7 @@
        p = VARDATA(pat);
        plen = (VARSIZE(pat) - VARHDRSZ);
 
-       if (pg_database_encoding_max_length() == 1)
-               result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
-       else
-               result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
+       result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
 
        PG_RETURN_BOOL(result);
 }
@@ -300,10 +276,7 @@
        p = VARDATA(pat);
        plen = (VARSIZE(pat) - VARHDRSZ);
 
-       if (pg_database_encoding_max_length() == 1)
-               result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
-       else
-               result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
+       result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
 
        PG_RETURN_BOOL(result);
 }
@@ -324,10 +297,7 @@
        p = VARDATA(pat);
        plen = (VARSIZE(pat) - VARHDRSZ);
 
-       if (pg_database_encoding_max_length() == 1)
-               result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
-       else
-               result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
+       result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
 
        PG_RETURN_BOOL(result);
 }
@@ -348,10 +318,7 @@
        p = VARDATA(pat);
        plen = (VARSIZE(pat) - VARHDRSZ);
 
-       if (pg_database_encoding_max_length() == 1)
-               result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
-       else
-               result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
+       result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
 
        PG_RETURN_BOOL(result);
 }
@@ -372,10 +339,7 @@
        p = VARDATA(pat);
        plen = (VARSIZE(pat) - VARHDRSZ);
 
-       if (pg_database_encoding_max_length() == 1)
-               result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
-       else
-               result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
+       result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
 
        PG_RETURN_BOOL(result);
 }
@@ -391,10 +355,7 @@
        text       *esc = PG_GETARG_TEXT_P(1);
        text       *result;
 
-       if (pg_database_encoding_max_length() == 1)
-               result = do_like_escape(pat, esc);
-       else
-               result = MB_do_like_escape(pat, esc);
+       result = do_like_escape(pat, esc);
 
        PG_RETURN_TEXT_P(result);
 }
Index: like_match.c
===================================================================
RCS file: /home/ncvs/pgsql/pgsql-server/src/backend/utils/adt/like_match.c,v
retrieving revision 1.4
diff -u -r1.4 like_match.c
--- like_match.c        3 Sep 2002 21:45:42 -0000       1.4
+++ like_match.c        23 Jun 2003 06:15:54 -0000
@@ -12,9 +12,9 @@
  * ICHAREQ
  * NextChar
  * CopyAdvChar
- * MatchText (MBMatchText)
- * MatchTextIC (MBMatchTextIC)
- * do_like_escape (MB_do_like_escape)
+ * MatchText
+ * MatchTextIC
+ * do_like_escape
  *
  * Copyright (c) 1996-2002, PostgreSQL Global Development Group
  *
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to