This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Fwd: [Patch, fortran] optimize string comparison
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 27 Mar 2013 19:59:58 +0100
- Subject: Re: Fwd: [Patch, fortran] optimize string comparison
- References: <20130327083557 dot GB6374 at domone dot kolej dot mff dot cuni dot cz> <5152B9FB dot 1090103 at net-b dot de>
On Wed, Mar 27, 2013 at 10:20:59AM +0100, Tobias Burnus wrote:
> (The email below was only sent to gcc-patches@; I now also CC
> fortran@ - sorry for the full quote)
>
> Regarding the below patch: I think it does not work as-is for
> Unicode strings (UCS4, character(kind=4)), where each character is 4
> bytes wide and a space does not consist of sequences of four ' '.
>
I did not know about that. We could use wmemchr when sizeof(wchar_t)==4.
where should I put that?
>
> Regarding Thomas' patch:* I would also think that memcmp should work
> for kind=4 characters; one then needs to multiply the length by the
> byte-size. (Actually, for kind==1, one could check the excess
> characters in the generated code via memchr as done in OndÅej's
> patch.)
>
>
> However, looking at intrinsics/string_intrinsics{,_inc}.c, I see
> that we don't use MEMCMP for UCS4 either - but some a hand-written
> function. I think that could also be replaced by the normal memcmp
> (or did I miss some fine print?). A possible patch would be to
> replace
> #define MEMCMP memcmp_char4
> by
> #define MEMCMP(a,b,c) memcmp(a,b,4*(c))
> and delete the memcmp_char4 function.
>
Or use wmemcmp.
>
> Tobias
>
> * http://gcc.gnu.org/ml/fortran/2013-03/msg00142.html
>