Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8c792fe

Browse files
committed
At the head of wchareq, length of (multibyte) character is compared by
using pg_mblen. Therefore, pg_mblen is executed many times, and itbecomes a bottleneck.This patch makes a short cut, and reduces execution frequency ofpg_mblen by comparing the first byte first.a_ogawa
1 parentbbb586f commit8c792fe

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

‎src/backend/utils/adt/like.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
1313
* IDENTIFICATION
14-
*$PostgreSQL: pgsql/src/backend/utils/adt/like.c,v 1.59 2004/12/31 22:01:22 pgsql Exp $
14+
*$PostgreSQL: pgsql/src/backend/utils/adt/like.c,v 1.60 2005/05/25 22:59:33 momjian Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -50,12 +50,18 @@ static text *MB_do_like_escape(text *, text *);
5050
staticint
5151
wchareq(unsignedchar*p1,unsignedchar*p2)
5252
{
53-
intl;
53+
intp1_len;
5454

55-
l=pg_mblen(p1);
56-
if (pg_mblen(p2)!=l)
55+
/* Optimization: quickly compare the first byte. */
56+
if(*p1!=*p2)
5757
return (0);
58-
while (l--)
58+
59+
p1_len=pg_mblen(p1);
60+
if (pg_mblen(p2)!=p1_len)
61+
return (0);
62+
63+
/* They are the same length */
64+
while (p1_len--)
5965
{
6066
if (*p1++!=*p2++)
6167
return (0);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp