Bug 487598 - improve efficiency of flatten utility

Signed-off-by: Rob Stryker <stryker@redhat.com>
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/VirtualComponentFlattenUtility.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/VirtualComponentFlattenUtility.java
index e59198a..be80836 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/VirtualComponentFlattenUtility.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/VirtualComponentFlattenUtility.java
@@ -105,8 +105,9 @@
 	}
 	
 	public void addFile(IVirtualComponent current, IPath path, IAdaptable file) {
-		IVirtualFile vf = (IVirtualFile)file.getAdapter(IVirtualFile.class);
-		IFile f = (IFile)file.getAdapter(IFile.class);
+                IVirtualFile vf = file instanceof IFile ? null : (IVirtualFile)file.getAdapter(IVirtualFile.class);
+                IFile f = file instanceof IFile ? (IFile)file : (IFile)file.getAdapter(IFile.class);
+
 		IFlatFile mf = null;
 		String vfName = null;
 		if( vf != null && vf.getName() != null )