commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Struberg (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LANG-508) Validate: add message parameter construction via elllipsis notation to speed up processing
Date Tue, 30 Jun 2009 09:37:47 GMT

    [ https://issues.apache.org/jira/browse/LANG-508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12725544#action_12725544
] 

Mark Struberg commented on LANG-508:
------------------------------------

Henri, thanks for reviewing!

Actually I didn't drop the String messages, and also didn't drop the 'more specialised' variants
like isTrue(boolean expression, String message, double value) for keeping binary compatibility.


See here for the resulting code (same commit as above, but without diffs):
http://github.com/struberg/commons-lang/blob/ed8515f63290eba6e38ff5b79772e87b27dde32b/src/java/org/apache/commons/lang/Validate.java

The only thing I did to them is to also use the private getMessage function internally instead
of the original simple string concatenation.

There are still a few things to clarify, as you can see in my '//X TODO' comments like in
the noNullElements function. But those are easy ones to fix.

txs and LieGrue,
strub


> Validate: add message parameter construction via elllipsis notation to speed up processing
> ------------------------------------------------------------------------------------------
>
>                 Key: LANG-508
>                 URL: https://issues.apache.org/jira/browse/LANG-508
>             Project: Commons Lang
>          Issue Type: Improvement
>    Affects Versions: 2.4
>            Reporter: Mark Struberg
>             Fix For: 3.0
>
>         Attachments: LANG-508.patch
>
>
> Currently passing verbose message strings to a log of commons.lang.Validate functions
costs a lot of performance.
> A typical usecase currently is:
> {noformat}
> Validate.isTrue (argInt1.intValue > argInt2.intValue, "param2 actually is " + argInt2
+ " but must larger than param1 " + argInt1 +" !");
> {noformat}
> So all the string operations get executed regardless if the validation fails or not.
> This can be made perform much better by moving all the string operations inside the respective
validation function and execute it only if the validation fails:
> {noformat}
> Validate.isTrue(argInt1.intValue > argInt2.intValue, "param2 actually is {1} but must
larger than param1 {0} !", argInt1, argInt2);
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message