Re: [PATCHES] Simplify formatting.c

2008-06-23 Thread Bruce Momjian
Euler Taveira de Oliveira wrote: > Tom Lane wrote: > > > Also, it seems a bit inconsistent to be relying on > > oracle_compat.c for upper/lower but not initcap. > > > I saw this inconsistence while I'm doing the patch. What about moving > that upper/lower/initcap and wcs* code to another file. p

Re: [PATCHES] Simplify formatting.c

2008-06-23 Thread Bruce Momjian
Bruce Momjian wrote: > > I am starting to think that the simplest case is to keep the single-copy > > version in there for single-byte encodings and not worry about the > > overhead of the multi-byte case. > > My new idea is if we pass the length to str_initcap, we can eliminate > the string copy

Re: [PATCHES] Simplify formatting.c

2008-06-22 Thread Bruce Momjian
Bruce Momjian wrote: > > Actually it seems like the hard part is not so much the input > > representation as the output representation --- what should the > > base-level initcap routine return, to be reasonably efficient for > > both cases? > > I hadn't gotten to trying it out yet, but I can see t

Re: [PATCHES] Simplify formatting.c

2008-06-21 Thread Bruce Momjian
Tom Lane wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: > > Tom Lane wrote: > >> I'd say not. Can't we do some more refactoring and avoid so many > >> useless conversions? Seems like str_initcap is the wrong primitive API > >> --- the work ought to be done by a function that takes a char poin

Re: [PATCHES] Simplify formatting.c

2008-06-21 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> I'd say not. Can't we do some more refactoring and avoid so many >> useless conversions? Seems like str_initcap is the wrong primitive API >> --- the work ought to be done by a function that takes a char pointer >> and a length. That

Re: [PATCHES] Simplify formatting.c

2008-06-21 Thread Bruce Momjian
Tom Lane wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: > > The third step is for oracle_compat.c::initcap() to use > > formatting.c::str_initcap(). You can see the result; patch attached > > (not applied). > > > This greatly reduces the size of initcap(), with the downside that we > > are m

Re: [PATCHES] Simplify formatting.c

2008-06-21 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > The third step is for oracle_compat.c::initcap() to use > formatting.c::str_initcap(). You can see the result; patch attached > (not applied). > This greatly reduces the size of initcap(), with the downside that we > are making two extra copies of the

Re: [PATCHES] Simplify formatting.c

2008-06-21 Thread Bruce Momjian
Bruce Momjian wrote: > Bruce Momjian wrote: > > Alvaro Herrera wrote: > > > Bruce Momjian wrote: > > > > > > > I moved str_initcap() over into oracle_compat.c and then had initcap() > > > > convert to/from TEXT to call it. The code is a little weird because > > > > str_initcap() needs to convert

Re: [PATCHES] Simplify formatting.c

2008-06-18 Thread Bruce Momjian
Bruce Momjian wrote: > Alvaro Herrera wrote: > > Bruce Momjian wrote: > > > > > I moved str_initcap() over into oracle_compat.c and then had initcap() > > > convert to/from TEXT to call it. The code is a little weird because > > > str_initcap() needs to convert to text to use texttowcs(), so in >

Re: [PATCHES] Simplify formatting.c

2008-06-17 Thread Bruce Momjian
Alvaro Herrera wrote: > Bruce Momjian wrote: > > > I moved str_initcap() over into oracle_compat.c and then had initcap() > > convert to/from TEXT to call it. The code is a little weird because > > str_initcap() needs to convert to text to use texttowcs(), so in > > multibyte encodings initcap co

Re: [PATCHES] Simplify formatting.c

2008-06-14 Thread Alvaro Herrera
Bruce Momjian wrote: > I moved str_initcap() over into oracle_compat.c and then had initcap() > convert to/from TEXT to call it. The code is a little weird because > str_initcap() needs to convert to text to use texttowcs(), so in > multibyte encodings initcap converts the string to text, then to

Re: [PATCHES] Simplify formatting.c

2008-06-13 Thread Bruce Momjian
Tom Lane wrote: > Euler Taveira de Oliveira <[EMAIL PROTECTED]> writes: > > Tom Lane wrote: > >> Also, it seems a bit inconsistent to be relying on > >> oracle_compat.c for upper/lower but not initcap. > >> > > I saw this inconsistence while I'm doing the patch. What about moving > > that upper/l

Re: [PATCHES] Simplify formatting.c

2008-05-20 Thread Tom Lane
Euler Taveira de Oliveira <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Also, it seems a bit inconsistent to be relying on >> oracle_compat.c for upper/lower but not initcap. >> > I saw this inconsistence while I'm doing the patch. What about moving > that upper/lower/initcap and wcs* code to

Re: [PATCHES] Simplify formatting.c

2008-05-20 Thread Euler Taveira de Oliveira
Tom Lane wrote: Also, it seems a bit inconsistent to be relying on oracle_compat.c for upper/lower but not initcap. I saw this inconsistence while I'm doing the patch. What about moving that upper/lower/initcap and wcs* code to another file. pg_locale.c? BTW, formatting.c and oracle_compat.c

Re: [PATCHES] Simplify formatting.c

2008-05-19 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Now that upper/lower/initcase do not modify the passed string, I have > simplified formatting.c with the attached patch. I was thinking the same thing while reading the patch. But please, make str_toupper() and friends declare their argument "const" if

[PATCHES] Simplify formatting.c

2008-05-19 Thread Bruce Momjian
Now that upper/lower/initcase do not modify the passed string, I have simplified formatting.c with the attached patch. -- Bruce Momjian <[EMAIL PROTECTED]>http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can