OSDN Git Service

Avoid unnecessary elimination of duplicated bigrams.
authorMasaoFujii <masao.fujii@gmail.com>
Wed, 21 May 2014 03:29:15 +0000 (12:29 +0900)
committerMasaoFujii <masao.fujii@gmail.com>
Wed, 21 May 2014 03:29:15 +0000 (12:29 +0900)
When the number of bigrams is only one, obviously there is
no duplicated bigrams and its elimination is not needed.

This commit comes from the change of PostgreSQL:
c3ccc9ee584b9b015dd9c1931e261e21f3961e5f

The issue which this commit has addressed is basically
harmless, but there is no strong reason not to back-patch
this. So back-patch to all supported versions.

Beena Emerson

bigm_op.c

index bb23c8d..84515b5 100644 (file)
--- a/bigm_op.c
+++ b/bigm_op.c
@@ -284,7 +284,10 @@ generate_bigm(char *str, int slen)
        if ((len = bptr - GETARR(bgm)) == 0)
                return bgm;
 
        if ((len = bptr - GETARR(bgm)) == 0)
                return bgm;
 
-       if (len > 0)
+       /*
+        * Make bigrams unique.
+        */
+       if (len > 1)
        {
                bool    haveDups = false;
 
        {
                bool    haveDups = false;
 
@@ -504,7 +507,7 @@ generate_wildcard_bigm(const char *str, int slen, bool *removeDups)
        /*
         * Make bigrams unique.
         */
        /*
         * Make bigrams unique.
         */
-       if (len > 0)
+       if (len > 1)
        {
                bool    haveDups = false;
 
        {
                bool    haveDups = false;