diff options
author | Thomas Watson | 2010-10-20 17:43:24 +0000 |
---|---|---|
committer | Thomas Watson | 2010-10-20 17:43:24 +0000 |
commit | b813b0893199c92d4e1f7011c91903cb2514eb3c (patch) | |
tree | 1d93b9aaf17f22dc1042d8b44e2084cea093f7e7 /bundles | |
parent | 1b30adb6e5eaf1ef4d9d4d3645fbefad39324379 (diff) | |
download | rt.equinox.framework-b813b0893199c92d4e1f7011c91903cb2514eb3c.tar.gz rt.equinox.framework-b813b0893199c92d4e1f7011c91903cb2514eb3c.tar.xz rt.equinox.framework-b813b0893199c92d4e1f7011c91903cb2514eb3c.zip |
Bug 309968 - Avoid call to File.isDirectory() to improve the performance of a cold start
Diffstat (limited to 'bundles')
-rw-r--r-- | bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java index 26e981380..2a6cb4863 100644 --- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java +++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java @@ -75,6 +75,11 @@ public class BaseStorage implements SynchronousBundleListener { */ public static final byte EXTENSION_UPDATED = 0x08; + /** The BundleData is for a bundle exploded in a directory */ + public static final int TYPE_DIRECTORYBUNDLE = 0x10000000; + /** The BundleData is for a bundle contained in a file (typically jar) */ + public static final int TYPE_FILEBUNDLE = 0x20000000; + /** * the file name for the delete flag. If this file exists in one a directory * under the bundle store area then it will be removed during the @@ -696,7 +701,7 @@ public class BaseStorage implements SynchronousBundleListener { // No factories configured or they declined to create the bundle file; do default if (result == null && content instanceof File) { File file = (File) content; - if (file.isDirectory()) + if (isDirectory(data, base, file)) result = new DirBundleFile(file); else result = new ZipBundleFile(file, data, this.mruList); @@ -721,6 +726,24 @@ public class BaseStorage implements SynchronousBundleListener { return result; } + private boolean isDirectory(BaseData data, boolean base, File file) { + if (!base) + // there is no other place to check this; just consult the file directly + return file.isDirectory(); + boolean isDirectory = false; + // first check if the type bits have been set + int type = data.getType(); + if ((type & (TYPE_DIRECTORYBUNDLE | TYPE_FILEBUNDLE)) == 0) { + // no type bits set; consult the file and save the result + isDirectory = file.isDirectory(); + data.setType(type | (isDirectory ? TYPE_DIRECTORYBUNDLE : TYPE_FILEBUNDLE)); + } else { + // type bits have been set check to see if this is a directory bundle. + isDirectory = (type & TYPE_DIRECTORYBUNDLE) != 0; + } + return isDirectory; + } + public synchronized StateManager getStateManager() { if (stateManager != null) return stateManager; |