borowiak / pwa-technologies

Automatically exported from code.google.com/p/pwa-technologies
0 stars 0 forks source link

Some methods invoke inefficient Number constructor #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Performance - Method invokes inefficient Number constructor; use static valueOf 
instead

Using new Integer(int) is guaranteed to always result in a new object whereas 
Integer.valueOf(int) allows caching of values to be done by the compiler, class 
library, or JVM. Using of cached values avoids object allocation and the code 
will be faster.

Values between -128 and 127 are guaranteed to have corresponding cached 
instances and using valueOf is approximately 3.5 times faster than using 
constructor. For values outside the constant range the performance of both 
styles is the same.

Unless the class must be compatible with JVMs predating Java 1.5, use either 
autoboxing or the valueOf() method when creating instances of Long, Integer, 
Short, Character, and Byte.

The offending classes are:
- org.archive.wayback.resourceindex.filters.MimeTypeFilter
- org.archive.access.nutch.jobs.TimeoutParsingThread
- org.archive.wayback.util.url.AggressiveUrlCanonicalizer

Original issue reported on code.google.com by devel.da...@vcruz.net on 2 Aug 2012 at 9:36

GoogleCodeExporter commented 9 years ago
Added a patch to solve the performance issue.

Original comment by devel.da...@vcruz.net on 8 Aug 2012 at 10:50

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by devel.da...@vcruz.net on 8 Aug 2012 at 11:08

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r442.

Original comment by devel.da...@vcruz.net on 29 Nov 2012 at 12:09