X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4DF799FA432 for ; Sat, 6 May 2006 06:40:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 14003-01 for ; Sat, 6 May 2006 06:40:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fep06.ttnet.net.tr (mail.ttnet.net.tr [212.175.13.129]) by postgresql.org (Postfix) with ESMTP id 7EA9C9F946D for ; Sat, 6 May 2006 06:40:47 -0300 (ADT) Received: from (192.168.8.106) by AVGW-I-7.ttnet.net.tr via smtp id 72a8_c06face0_dcb1_11da_8047_001143376e77; Sat, 06 May 2006 06:38:15 +0300 Received: from alamut ([85.102.236.143]) by fep06.ttnet.net.tr with ESMTP id <20060506094045.FZOH1265.fep06.ttnet.net.tr@alamut> for ; Sat, 6 May 2006 12:40:45 +0300 Date: Sat, 6 May 2006 12:38:25 +0300 From: Volkan YAZICI To: pgsql-general@postgresql.org Subject: Re: intarray internals Message-ID: <20060506093825.GA202@alamut> References: <20060505214601.GA208@alamut> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060505214601.GA208@alamut> User-Agent: Mutt/1.4.2.1i X-NAI-Spam-Rules: 1 Rules triggered BAYES_00=-2.5 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/249 X-Sequence-Number: 95041 On May 06 12:46, Volkan YAZICI wrote: > I'm reading through the source code of intarray contrib module. Despite > being at the beginning, I've some questions to ask. I'd be so > appreciated if anybody can help. Sorry, I forgot one: [4] In the inner_int_contains() function of _int_tool.c, there's a while loop like [Code assumes that arrays are sorted.] na = ARRNELEMS(a); nb = ARRNELEMS(b); da = ARRPTR(a); db = ARRPTR(b); i = j = n = 0; while (i < na && j < nb) if (da[i] < db[j]) i++; else if (da[i] == db[j]) { n++; i++; j++; } else j++; return (n == nb) ? TRUE : FALSE; AFAICS, last "j++" should be replaced with "return FALSE". Because, "n" cannot be equal to "nb" no more, if "j" gets incremented without incrementing "n" (remember "j < nb" in the "while" condition). Regards.