Bug 296999 - [performance] Inefficient use of new String() constructor
Summary: [performance] Inefficient use of new String() constructor
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: David Carver CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2009-12-05 11:36 EST by David Carver CLA
Modified: 2010-01-10 18:35 EST (History)
0 users

See Also:


Attachments
Patch to correct memory performance (52.10 KB, patch)
2009-12-05 11:43 EST, David Carver CLA
no flags Details | Diff
Refactored to make an EMPTY_STRING constant (62.66 KB, patch)
2009-12-05 17:13 EST, David Carver CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Carver CLA 2009-12-05 11:36:52 EST
I ran FindBugs against the wst.xml.core plugin and one of the items it reported was the inefficient use of new String().  It suggests for performance and memory usage that the constant "" be used as java compilers and jvms will use the reference to the constant instead of creating new objects everytime. 

I'll attach a patch that addresses this issue in various parts of the core code.
Comment 1 David Carver CLA 2009-12-05 11:43:27 EST
Created attachment 153863 [details]
Patch to correct memory performance
Comment 2 David Carver CLA 2009-12-05 17:13:19 EST
Created attachment 153873 [details]
Refactored to make an EMPTY_STRING constant

Refactored to make an XMLCorePlugin.EMPTY_STRING constant that can be used.
Comment 3 Nitin Dahyabhai CLA 2010-01-10 18:35:42 EST
Mostly applied, except I made the string a package protected constant in NodeImpl itself and had the formatter classes use the existing NodeFormatter#EMPTY_STRING constant instead.