commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r390186 - in /jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider: AbstractFileName.java UriParser.java local/LocalFile.java local/LocalFileSystem.java local/WindowsFileNameParser.java
Date Thu, 30 Mar 2006 17:40:19 GMT
Author: imario
Date: Thu Mar 30 09:40:17 2006
New Revision: 390186

URL: http://svn.apache.org/viewcvs?rev=390186&view=rev
Log:
intern() some string to preserve memory. some performance speedup in filename handling

Thanks to Anthony Goubard.

Modified:
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java?rev=390186&r1=390185&r2=390186&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
Thu Mar 30 09:40:17 2006
@@ -30,6 +30,7 @@
 public abstract class AbstractFileName
     implements FileName
 {
+    
     private final String scheme;
     private final String absPath;
     private FileType type;
@@ -310,7 +311,7 @@
             final StringBuffer buffer = new StringBuffer();
             appendRootUri(buffer);
             buffer.append(SEPARATOR_CHAR);
-            rootUri = buffer.toString();
+            rootUri = buffer.toString().intern();
         }
         return rootUri;
     }
@@ -354,7 +355,7 @@
             }
             else
             {
-                extension = baseName.substring(pos + 1);
+                extension = baseName.substring(pos + 1).intern();
             }
         }
         return extension;

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java?rev=390186&r1=390185&r2=390186&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java
Thu Mar 30 09:40:17 2006
@@ -246,7 +246,7 @@
 				{
 					buffer.delete(0, pos + 1);
 				}
-				return scheme;
+				return scheme.intern();
 			}
 
 			if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
@@ -280,6 +280,10 @@
 		if (encodedStr == null)
 		{
 			return null;
+		}
+		if (encodedStr.indexOf('%') < 0)
+		{
+			return encodedStr;
 		}
 		final StringBuffer buffer = new StringBuffer(encodedStr);
 		decode(buffer, 0, buffer.length());

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java?rev=390186&r1=390185&r2=390186&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
Thu Mar 30 09:40:17 2006
@@ -42,17 +42,14 @@
     implements FileObject
 {
     private File file;
-    private final String fileName;
 
     /**
      * Creates a non-root file.
      */
     protected LocalFile(final LocalFileSystem fileSystem,
-                        final String fileName,
                         final FileName name) throws FileSystemException
     {
         super(name, fileSystem);
-        this.fileName = UriParser.decode(fileName);
     }
 
     /**
@@ -71,6 +68,9 @@
     {
         if (file == null)
         {
+            // Remove the "file:///"
+            String fileName = getName().getPathDecoded();
+            // fileName = UriParser.decode(fileName);
             file = new File(fileName);
         }
     }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java?rev=390186&r1=390185&r2=390186&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java
Thu Mar 30 09:40:17 2006
@@ -53,8 +53,7 @@
     protected FileObject createFile(final FileName name) throws FileSystemException
     {
         // Create the file
-        String fileName = rootFile + name.getPath();
-        return new LocalFile(this, fileName, name);
+        return new LocalFile(this, name);
     }
 
     /**

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java?rev=390186&r1=390185&r2=390186&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java
Thu Mar 30 09:40:17 2006
@@ -113,7 +113,8 @@
 
         String prefix = name.substring(0, 2);
         name.delete(0, 2);
-        return prefix;
+        
+        return prefix.intern();
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message