[ 
https://issues.apache.org/jira/browse/OFBIZ-11020?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17028091#comment-17028091
 ] 

Michael Brohl commented on OFBIZ-11020:
---------------------------------------

Hi [~bd2019us] ,

thanks for your contribution.

Your patch does not apply directly for current trunk. Also, is there a reason 
why you replaces Math.random only partially?

See CommonEvents:
{code:java}
            for (int i = 0; i < circlesToDraw; i++) {
                Random rand = new Random();
                int circleRadius = (int) (rand.nextDouble() * height / 2.0);
                int circleX = (int) (Math.random() * width - circleRadius);
                int circleY = (int) (Math.random() * height - circleRadius);
                g.drawOval(circleX, circleY, circleRadius * 2, circleRadius * 
2);
            }
{code}

> Use Random.nextDouble() instead of Math.random()
> ------------------------------------------------
>
>                 Key: OFBIZ-11020
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-11020
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: bd2019us
>            Assignee: Michael Brohl
>            Priority: Trivial
>         Attachments: OFBIZ-11020.patch
>
>
> When using Math.random instead of Random.nextDouble, there is a slight 
> performance cost. Due to Math.random invoking an instance of Random This cost 
> can be alleviated by directly using Random.nextDouble. This also allows for 
> more control over the randomization in the future.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to