Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOipV-0005sa-7K for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Dec 2017 11:34:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOipU-0003gi-QV for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Dec 2017 11:34:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eOior-0007I5-41; Tue, 12 Dec 2017 11:33:53 +0000 Received: from hook.sigaev.ru ([93.180.27.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eOion-0007bE-1P; Tue, 12 Dec 2017 11:33:51 +0000 Received: from xor.sai.msu.ru (unknown [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: teodor) by hook.sigaev.ru (Postfix) with ESMTPSA id BA25EB191C1; Tue, 12 Dec 2017 14:33:47 +0300 (MSK) Subject: Re: Fwd: [BUGS] pg_trgm word_similarity inconsistencies or bug To: Alexander Korotkov , Robert Haas Cc: =?UTF-8?Q?Jan_Przemys=c5=82aw_W=c3=b3jcik?= , Postgres-Bugs , "pgsql-hackers@postgresql.org" References: <20171028082225.GA2157@arthur.localdomain> <1510059095836-0.post@n3.nabble.com> From: Teodor Sigaev Message-ID: <42a3a2a4-59b9-c932-3bdf-e346e7b2e406@sigaev.ru> Date: Tue, 12 Dec 2017 14:33:47 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > 0002-pg-trgm-strict_word-similarity.patch – implementation of > strict_word_similarity() with comments, docs and tests. After some looking in 1) repeated piece of code: + if (strategy == SimilarityStrategyNumber) + nlimit = similarity_threshold; + else if (strategy == WordSimilarityStrategyNumber) + nlimit = word_similarity_threshold; + else /* strategy == StrictWordSimilarityStrategyNumber */ + nlimit = strict_word_similarity_threshold; Isn't it better to move that piece to separate function? 2) calc_word_similarity(char *str1, int slen1, char *str2, int slen2, bool check_only, bool word_bounds) Seems, two bools args are replaceble to bitwise-ORed flag. It will simplify adding new options in future. -- Teodor Sigaev E-mail: teodor@sigaev.ru WWW: http://www.sigaev.ru/