logo       

bk commit into 4.0 tree (1.1468): msg#00361

db.mysql.devel

Subject: bk commit into 4.0 tree (1.1468)

Below is the list of changes that have just been committed into a local
4.0 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
1.1468 03/04/25 21:28:11 hf@xxxxxxxxxxxxxxxxx +1 -0
Trimming code with Monty's suggestions

strings/ctype-tis620.c
1.20 03/04/25 21:28:06 hf@xxxxxxxxxxxxxxxxx +82 -90
thai2sortable code optimized
all the file formatted with company standards

# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: hf
# Host: deer.mysql.r18.ru
# Root: /home/hf/work/mysql-4.0.erf

--- 1.19/strings/ctype-tis620.c Fri Apr 25 16:26:22 2003
+++ 1.20/strings/ctype-tis620.c Fri Apr 25 21:28:06 2003
@@ -453,82 +453,78 @@
Arg: const source string and length of converted string
Ret: Sortable string
*/
-
+/*
+ NOTE: isn't it faster to alloc buffer in calling function?
+ */
static uchar* thai2sortable(const uchar * tstr,uint len)
{
/* We use only 3 levels (neglect capitalization). */

- const uchar* p = tstr;
+ const uchar* p= tstr;
uchar *outBuf;
-/* uchar *pRight1, *pRight2, *pRight3, *pRight4; */
-/* uchar *pLeft1, *pLeft2, *pLeft3, *pLeft4; */
uchar *pRight1, *pRight2, *pRight3;
uchar *pLeft1, *pLeft2, *pLeft3;
uint bufSize;
+ uint RightSize;

- len = (uint) strnlen((char*) tstr,len);
- bufSize = (uint) buffsize((char*) tstr);
- if(!(pRight1 = (uchar *)malloc(sizeof(uchar) * bufSize))) {
- return( (uchar*) tstr);
- }
- pLeft1 = pRight1;
- outBuf = pRight1;
- if(!(pRight2 = (uchar *)malloc(sizeof(uchar) * (len + 1)))) {
- free(pRight1);
- return((uchar*) tstr);
- }
- pLeft2 = pRight2;
- if(!(pRight3 = (uchar *)malloc(sizeof(uchar) * (len + 1)))) {
- free(pRight1);
- free(pRight2);
- return((uchar*) tstr);
- }
- pLeft3 = pRight3;
-/* if(!(pRight4 = (uchar *)malloc(sizeof(uchar) * (len + 1)))) {
- free(pRight1);
- free(pRight2);
- free(pRight3);
- return((uchar*) tstr);
- }
- pLeft4 = pRight4;*/
- while(len--) {
- if(isldvowel(*p) && len > 0 && isconsnt(p[1])) {
- *pRight1++ = t_ctype[p[1]][0];
- *pRight2++ = t_ctype[p[1]][1];
- *pRight3++ = t_ctype[p[1]][2];
-/* *pRight4++ = t_ctype[p[1]][3]; */
- *pRight1++ = t_ctype[*p][0];
- *pRight2++ = t_ctype[*p][1];
- *pRight3++ = t_ctype[*p][2];
-/* *pRight4++ = t_ctype[*p][3]; */
+ len= (uint) strnlen((char*) tstr,len);
+ bufSize= (uint) buffsize((char*) tstr);
+ RightSize= sizeof(uchar) * (len + 1);
+ if (!(outBuf= pLeft1= pRight1=
+ (uchar *)malloc(sizeof(uchar) * bufSize + RightSize*2)))
+ return (uchar*) tstr;
+ pLeft2= pRight2= pRight1 + sizeof(uchar) * bufSize;
+ pLeft3= pRight3= pRight2 + RightSize;
+
+ while (--len)
+ {
+ int *t_ctype0= t_ctype[p[0]];
+ if (isldvowel(*p) && isconsnt(p[1]))
+ {
+ int *t_ctype1= t_ctype[p[1]];
+ *pRight1++= t_ctype1[0];
+ *pRight2++= t_ctype1[1];
+ *pRight3++= t_ctype1[2];
+ *pRight1++= t_ctype0[0];
+ *pRight2++= t_ctype0[1];
+ *pRight3++= t_ctype0[2];
+ p+= 2;
len--;
- p += 2;
- } else {
- *pRight1 = t_ctype[*p][0];
- if(*pRight1 != IGNORE) pRight1++;
- *pRight2 = t_ctype[*p][1];
- if(*pRight2 != IGNORE) pRight2++;
- *pRight3 = t_ctype[*p][2];
- if(*pRight3 != IGNORE) pRight3++;
-/* *pRight4 = t_ctype[*p][3];
- if(*pRight4 != IGNORE) pRight4++;*/
+ }
+ else
+ {
+ *pRight1= t_ctype0[0];
+ if(*pRight1 != IGNORE)
+ pRight1++;
+ *pRight2= t_ctype0[1];
+ if (*pRight2 != IGNORE)
+ pRight2++;
+ *pRight3= t_ctype0[2];
+ if(*pRight3 != IGNORE)
+ pRight3++;
p++;
}
}
- *pRight1++ = L2_BLANK;
- *pRight2++ = L3_BLANK;
-/* *pRight3++ = L4_BLANK; */
- *pRight3++ = '\0';
-/* *pRight4++ = '\0'; */
+ if (!len)
+ {
+ int *t_ctype0= t_ctype[p[0]];
+ *pRight1= t_ctype0[0];
+ if (*pRight1 != IGNORE)
+ pRight1++;
+ *pRight2= t_ctype0[1];
+ if (*pRight2 != IGNORE)
+ pRight2++;
+ *pRight3= t_ctype0[2];
+ if (*pRight3 != IGNORE)
+ pRight3++;
+ }
+ *pRight1++= L2_BLANK;
+ *pRight2++= L3_BLANK;
+ *pRight3++= '\0';
memcpy(pRight1, pLeft2, pRight2 - pLeft2);
- pRight1 += pRight2 - pLeft2;
+ pRight1+= pRight2 - pLeft2;
memcpy(pRight1, pLeft3, pRight3 - pLeft3);
-/* pRight1 += pRight3 - pLeft3; */
-/* memcpy(pRight1, pLeft4, pRight4 - pLeft4); */
- free(pLeft2);
- free(pLeft3);
-/* free(pLeft4); */
- return(outBuf);
+ return outBuf;
}

/* strncoll() replacement, compare 2 string, both are conveted to sortable
string
@@ -539,12 +535,12 @@
{
uchar *tc1, *tc2;
int i;
- tc1 = thai2sortable(s1, len1);
- tc2 = thai2sortable(s2, len2);
- i = strcmp((char*)tc1, (char*)tc2);
+ tc1= thai2sortable(s1, len1);
+ tc2= thai2sortable(s2, len2);
+ i= strcmp((char*)tc1, (char*)tc2);
free(tc1);
free(tc2);
- return(i);
+ return i;
}

/* strnxfrm replacment, convert Thai string to sortable string
@@ -555,12 +551,12 @@
{
uint bufSize;
uchar *tmp;
- bufSize = (uint) buffsize((char*)src);
- tmp = thai2sortable(src,srclen);
+ bufSize= (uint) buffsize((char*)src);
+ tmp= thai2sortable(src,srclen);
set_if_smaller(bufSize,(uint) len);
memcpy((uchar *)dest, tmp, bufSize);
free(tmp);
- return (int) bufSize;
+ return (int)bufSize;
}

/* strcoll replacment, compare 2 strings
@@ -571,12 +567,12 @@
{
uchar *tc1, *tc2;
int i;
- tc1 = thai2sortable(s1, (uint) strlen((char*)s1));
- tc2 = thai2sortable(s2, (uint) strlen((char*)s2));
- i = strcmp((char*)tc1, (char*)tc2);
+ tc1= thai2sortable(s1, (uint) strlen((char*)s1));
+ tc2= thai2sortable(s2, (uint) strlen((char*)s2));
+ i= strcmp((char*)tc1, (char*)tc2);
free(tc1);
free(tc2);
- return(i);
+ return i;
}

/* strxfrm replacment, convert Thai string to sortable string
@@ -588,9 +584,9 @@
uint bufSize;
uchar *tmp;

- bufSize = (uint) buffsize((char*) src);
- tmp = thai2sortable(src, len);
- memcpy((uchar *) dest, tmp, bufSize);
+ bufSize= (uint)buffsize((char*) src);
+ tmp= thai2sortable(src, len);
+ memcpy((uchar *)dest, tmp, bufSize);
free(tmp);
return bufSize;
}
@@ -620,7 +616,7 @@
if (*ptr == escape && ptr+1 != end)
{
ptr++; /* Skipp escape */
- *min_str++= *max_str++ = *ptr;
+ *min_str++ = *max_str++ = *ptr;
continue;
}
if (*ptr == wild_one) /* '_' in SQL */
@@ -654,26 +650,22 @@
*/
void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length)
{
- const uchar* fr = from;
- uchar* p = ptr;
+ const uchar* fr= from;
+ uchar* p= ptr;
+
+ if (length > field_length)
+ length= field_length;

- if(length > field_length) {
- length = field_length;
- }
while (length--)
- {
- if((istone(*fr) || isdiacrt1(*fr)) &&
+ if ((istone(*fr) || isdiacrt1(*fr)) &&
(islwrvowel(fr[1]) || isuprvowel(fr[1])))
{
- *p = fr[1];
- p[1] = *fr;
- fr += 2;
- p += 2;
+ *p= fr[1];
+ p[1]= *fr;
+ fr+= 2;
+ p+= 2;
length--;
}
else
- {
*p++ = *fr++;
- }
- }
}

--
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:
http://lists.mysql.com/internals?unsub=gcdmd-internals@xxxxxxxxxxx




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise