[jira] [Commented] (VELOCITY-979) Performance issue with comparing strings in Velocity

"Claude Brisson (Jira)" <[email protected]>
Newsgroups gmane.comp.jakarta.velocity.devel
Message-ID <[email protected]>
    [ https://issues.apache.org/jira/browse/VELOCITY-979?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876422#comment-17876422 ] 

Claude Brisson commented on VELOCITY-979:
-----------------------------------------

This should be fixed by [https://github.com/apache/velocity-engine/pull/48]

I'm gonna be optimistically lazy and close this issue once the PR is merged since it's most obviously the cause.

 

> Performance issue with comparing strings in Velocity
> ----------------------------------------------------
>
>                 Key: VELOCITY-979
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-979
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 2.3
>            Reporter: Alex
>            Priority: Major
>
> Most Velocity compare expressions eventually use ASTComparisonNode which at first attempts to treat data types as numbers:
>  
> Boolean result = compareNumbers(left, right);
> if (result == null)
> {
> result = compareNonNumber(left, right);
> }
>  
> There is fairly large overhead when attempting to create BigDecimal from non-numeric strings used in comparison in the DuckType.asNumber:
>  
> if (coerceType)
> {
> String string = asString(value);// coerce to string
> if (string != null)
> {
> return new BigDecimal(string);
> }
> }
>  
> The exception is created capturing stack, etc. On large volume of compare operations it's very visible.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.