From: | Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: intarray internals |
Date: | 2006-05-08 19:38:02 |
Message-ID: | 20060508193802.GA211@alamut |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
Hi,
[I'm trying to share some of my thoughts about intarray contrib module.
If this is the wrong way to achieve this, please warn me. (Should I
first get in touch with Teodor Sigaev and Oleg Bartunov?)]
[6]
_int_same() in _int_op.c looks like making some redundant sorting and
not taking advantage of sorted arrays while comparing each other. Here's
the related code piece:
SORT(a);
SORT(b);
na = ARRNELEMS(a);
nb = ARRNELEMS(b);
da = ARRPTR(a);
db = ARRPTR(b);
result = FALSE;
if (na == nb)
{
result = TRUE;
for (n = 0; n < na; n++)
if (da[n] != db[n])
{
result = FALSE;
break;
}
}
IMHO, SORT() macro should be called after "if (na == nb)" block. (SORT()
doesn't remove duplicates.) Also, in the inner block, while comparing
two arrays, we can take advantage of sorting of arrays. While current
behaviour is like
if (A[0] == B[0] && A[1] == B[1] && ...)
we can replace it with sth like
if (A[0] == B[0] && A[ N] == B[ N] &&
A[1] == B[1] && A[N-1] == B[N-1] &&
...)
Attached patch tries to implement both behaviours mentioned above and
some minor hacking for arrays of 1,2 and 3 items.
Regards.
Attachment | Content-Type | Size |
---|---|---|
intarray_same.patch.0 | text/plain | 2.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-05-08 19:58:29 | Re: intarray internals |
Previous Message | George Pavlov | 2006-05-08 19:37:46 | Re: Using the REPLACE command to replace all vowels |
From | Date | Subject | |
---|---|---|---|
Next Message | Jeffrey Tenny | 2006-05-08 19:43:39 | Re: performance question (something to do w/ parameterized |
Previous Message | Magnus Hagander | 2006-05-08 18:27:14 | Re: Pragma linking? |