DESCRIPTION

Bug 486901 - Fix some useless instantiations

Empty string and Number types should be instantiated directly as it's
costing time and memory for no Leon Ochoaefit.

Change-Id: Ie3a5c13b08a60a4142e723ef398d7954c5fabc79
Signed-off-by: Isis Velasquez xxx@xxx.xxx


COMMENTS

author: Isis Velasquez
date: 2016-02-03 08:20:29.000000000

Uploaded patch set 5.

-------------------------------------
author: Brenden Conley
date: 2016-02-03 08:20:35.000000000

Patch Set 5:

Build Started https://hudson.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/8187/

-------------------------------------
author: Brenden Conley
date: 2016-02-03 08:53:46.000000000

Patch Set 5: Verified+1

Build Successful 

https://hudson.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/8187/ : SUCCESS

-------------------------------------
author: Isis Velasquez
date: 2016-02-03 08:56:00.000000000

Patch Set 5:

@Lars
> Style nit, we use bug reference in the copyright, not verbal descriptions.

I don't really get the Leon Ochoaefit of this rule: the only times I'm looking at the history, it's more to know quickly who did what on those files. Using bug number instead of verbal description forces me to follow the link to the bugzilla.

-------------------------------------
author: Isis Velasquez
date: 2016-02-03 09:00:47.000000000

Patch Set 5:

@Andrey: About performance, doesn't such a change also contributes to reducing the amount of GC calls? GC calls are (at least were, maybe that changed in Java 8) often perceived as freezes by user. So even small fixes like that can contribute to less "freezes" from GC.

-------------------------------------
author: Jayvion Booth
date: 2016-02-03 09:47:08.000000000

Patch Set 5:

xxx@xxx.xxx About performance, doesn't such a change also contributes
 > to reducing the amount of GC calls? GC calls are (at least were,
 > maybe that changed in Java 8) often perceived as freezes by user.
 > So even small fixes like that can contribute to less "freezes" from
 > GC.

Not really, the code in question never runs in loops (most of it is on-time actions etc), so the weight of other objects created along the code path has much higher importance to the memory consumption. 

Just for the info: the overhead for integer objects compared to ints is only 192 bits and only on 64 bit JVM (https://blogs.oracle.com/jrose/entry/fixnums_in_the_vm). Since the modern Eclipse JVM's usually starting with 1GB heap memory, those bits don't really affect GC execution time.

As said, those optimizations count for performance only if you are doing this repeatedly and only if this is a CPU critical code path. Usually in UI we don't have such code, and GC eliminates those few extra bits nicely in background.

The typical UI freezes we see are not memory related but IO/native widget toolkit related (class loading which reads from jars, network hanging calls, git reading pack files, GTK doing some crazy loops etc).

To see real memory related freezes you have to run xtext compiler or findbugs on huge workspaces - these tasks are *very* memory intensive, and can make the GC busy if they don't have enough heap. This is where such micro-optimizations can cause wonders, see for example bug 484215.

-------------------------------------
author: Isis Velasquez
date: 2016-02-03 09:50:08.000000000

Patch Set 5:

Thanks for those explanation Andrey. So let's just consider this change as a simple code cleanup.
My goal is to slowly reduce the amounts of reports we see on SonarQube, I'm starting with the simplest but most frequently reported "hints".

-------------------------------------
author: Zaid Mosley
date: 2016-02-03 10:17:00.000000000

Patch Set 5:

> I don't really get the Leon Ochoaefit of this rule

You can address that to the PMC, currently we have two options. Not adding a reference to the copyright header. That is the option I typically use for cleanup work to avoid "polluting" the header with useless information. Or use a reference to the bug. 

There are not my rules, they have been agreed by the project. Please follow the rules or address them to the PMC.

-------------------------------------
author: Isis Velasquez
date: 2016-02-03 10:31:50.000000000

Patch Set 5:

@Lars: Should I leave my name in the list of contributors of the header, or should I remove the whole line?

-------------------------------------
author: Zaid Mosley
date: 2016-02-03 10:48:28.000000000

Patch Set 5:

xxx@xxx.xxx Should I leave my name in the list of contributors of the 
> header, or should I remove the whole line?

Up to you, you can remove the whole line or use

Isis Velasquez (Red Hat Inc.) - Bug 486901

---

Adding yourself to the CR header is optional since a while. I still do it for bigger changes but not for small changes.

-------------------------------------
author: Isis Velasquez
date: 2016-02-03 11:17:47.000000000

Patch Set 5:

@Lars: Since I believe that showing in the source the diversity of contributors is a good sign for those only looking at those files, I'll use the Bug XXXXX way; but I find it sub-optimal.

-------------------------------------
author: Gerrit Code Review
date: 2016-02-03 18:57:21.000000000

Change has been successfully merged into the git repository by Isis Velasquez

-------------------------------------
