[Title] Change iteraction string compare to the hash set for performance
authorho.namkoong <ho.namkoong@samsung.com>
Fri, 9 Nov 2012 07:28:38 +0000 (16:28 +0900)
committerho.namkoong <ho.namkoong@samsung.com>
Fri, 9 Nov 2012 07:28:38 +0000 (16:28 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: Ifa9c6738a78559498f5c8f20c853b34173b6b00d

org.tizen.common/src/org/tizen/common/util/FileUtil.java

index 34fc54c..5fe5d3c 100755 (executable)
@@ -39,6 +39,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.util.HashSet;
 import java.util.Stack;
 
 import org.tizen.common.util.log.Logger;
@@ -432,6 +433,10 @@ public class FileUtil {
     }
 
     private static void copyRecursivelyWithoutDirChecking(File fromDir, File toDir, boolean overwrite, File... filters) throws IOException {
+        HashSet<String> filterSet = new HashSet<String>();
+        for(File filter: filters) {
+            filterSet.add(filter.getCanonicalPath());
+        }
         Stack<File> fromFileStack = new Stack<File>();
         Stack<File> toFileStack = new Stack<File>();
         
@@ -455,11 +460,9 @@ public class FileUtil {
                 if(!toFile.exists() || !toFile.isFile() || overwrite) {
                     boolean found = false;
                     if(filters != null) {
-                        for(File filter: filters) {
-                            if(filter.getCanonicalPath().equals(fromFile.getCanonicalPath())) {
-                                found = true;
-                                break;
-                            }
+                        if(filterSet.contains(fromFile.getCanonicalPath())) {
+                            found = true;
+                            break;
                         }
                     }
                     if(!found) {