geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1629810 - /geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java
Date Tue, 07 Oct 2014 06:46:22 GMT
Author: struberg
Date: Tue Oct  7 06:46:22 2014
New Revision: 1629810

URL: http://svn.apache.org/r1629810
Log:
XBEAN-274 improve performance by rewriting replaceFirst with endsWith + substring.

The code just removes a ".class" at the end of the entry name. 
Overall performance of finder improved by as much as 20%.

Modified:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java?rev=1629810&r1=1629809&r2=1629810&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java
Tue Oct  7 06:46:22 2014
@@ -103,12 +103,16 @@ public class JarArchive implements Archi
             if (!stream.hasMoreElements()) return false;
 
             final JarEntry entry = stream.nextElement();
+            final String entryName = entry.getName();
 
-            if (entry.isDirectory() || !entry.getName().endsWith(".class")) {
+            if (entry.isDirectory() || !entryName.endsWith(".class")) {
                 return advance();
             }
 
-            final String className = entry.getName().replaceFirst(".class$", "");
+            String className = entryName;
+            if (entryName.endsWith(".class")) {
+                className = className.substring(0, className.length() - 6);
+            }
 
             if (className.contains(".")) {
                 return advance();



Mime
View raw message