You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-dev@jakarta.apache.org by Oleg Sukhodolsky <so...@ppson.spb.ru> on 2004/03/20 15:00:17 UTC

[PATCH] some refactoring for char comparison

Hi,

during source browsing I found that in every place where we need to
compare characters we do the following:
if (caseIndependent)
{
    // compare substrings case-insensitively
}
else
{
    // compare substrings normally
}

So, I suggest to add new method which will compare two characters in
required mode (something like compareChars(char c1, char c2, boolean caseIndependent))
and use it in all cases this reduces the code size and simplifies it.
It may cause some performance degradation, but it shouldn't be
significant (almost all JVM can optimize calls of private methods).
So, here are suggested changes: full-simplification.txt - unified diffs
and full-simplification-cdiffs.txt - context diffs (they are easier to
read IMHO).

I've also added several tests to cover changed code.

Do you agree with such changes?

With best regards, Oleg.

Re: [PATCH] some refactoring for char comparison

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Oleg Sukhodolsky wrote:

>Hi,
>
>during source browsing I found that in every place where we need to
>compare characters we do the following:
>if (caseIndependent)
>{
>    // compare substrings case-insensitively
>}
>else
>{
>    // compare substrings normally
>}
>
>So, I suggest to add new method which will compare two characters in
>required mode (something like compareChars(char c1, char c2, boolean caseIndependent))
>and use it in all cases this reduces the code size and simplifies it.
>It may cause some performance degradation, but it shouldn't be
>significant (almost all JVM can optimize calls of private methods).
>So, here are suggested changes: full-simplification.txt - unified diffs
>and full-simplification-cdiffs.txt - context diffs (they are easier to
>read IMHO).
>  
>

Looks good, patch applied.


>I've also added several tests to cover changed code.
>  
>

Excellent.

Thanks,
Vadim


---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-dev-help@jakarta.apache.org