{"action":"closed","issue":{"url":"https://api.github.com/repos/TSedlar/Sedlar-Bytecode/issues/5","labels_url":"https://api.github.com/repos/TSedlar/Sedlar-Bytecode/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/TSedlar/Sedlar-Bytecode/issues/5/comments","events_url":"https://api.github.com/repos/TSedlar/Sedlar-Bytecode/issues/5/events","html_url":"https://github.com/TSedlar/Sedlar-Bytecode/issues/5","id":59202739,"number":5,"title":"Speed up jar loading","user":{"login":"smithtrenton","id":581684,"avatar_url":"https://avatars.githubusercontent.com/u/581684?v=3","gravatar_id":"","url":"https://api.github.com/users/smithtrenton","html_url":"https://github.com/smithtrenton","followers_url":"https://api.github.com/users/smithtrenton/followers","following_url":"https://api.github.com/users/smithtrenton/following{/other_user}","gists_url":"https://api.github.com/users/smithtrenton/gists{/gist_id}","starred_url":"https://api.github.com/users/smithtrenton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smithtrenton/subscriptions","organizations_url":"https://api.github.com/users/smithtrenton/orgs","repos_url":"https://api.github.com/users/smithtrenton/repos","events_url":"https://api.github.com/users/smithtrenton/events{/privacy}","received_events_url":"https://api.github.com/users/smithtrenton/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-02-27T08:02:44Z","updated_at":"2015-05-15T02:28:35Z","closed_at":"2015-05-15T02:28:35Z","body":"I made jar loading concurrent, but it's really ugly. I'm sure there is a cleaner way.\r\n```java\r\npublic Map<String, ClassInfo> buildConcurrent() {\r\n\t\tif (!classes.isEmpty())\r\n\t\t\treturn classes;\r\n\t\tlong start = System.nanoTime();\r\n        try (JarFile jar = new JarFile(file)) {\r\n            CopyOnWriteArrayList<String> toRemove = new CopyOnWriteArrayList();\r\n            Enumeration<JarEntry> enumeration = jar.entries();\r\n            HashMap<String, InputStream> inputStreams = new HashMap();\r\n            for (JarEntry entry : Collections.list(jar.entries()))\r\n                inputStreams.put(entry.getName(), jar.getInputStream(entry));\r\n            jar.stream().parallel().forEach(entry -> {\r\n                String entryName = entry.getName();\r\n                InputStream stream = inputStreams.get(entryName);\r\n                if (entryName.endsWith(\".class\")) {\r\n                    byte[] bytes = Streams.binary(stream);\r\n                    try {\r\n                        classes.put(entryName.replace(\".class\", \"\"), new ClassInfo(bytes));\r\n                    } catch (IOException|InvalidByteCodeException e) {\r\n                        toRemove.add(entryName.replace(\".class\", \"\"));\r\n                    }\r\n                } else if (keepResources) {\r\n                    byte[] bytes = Streams.binary(stream);\r\n                    resources.put(entryName, bytes);\r\n                }\r\n            });\r\n            if (toRemove.size() > 0)\r\n                return null;\r\n        } catch (IOException e) {\r\n            return null;\r\n        }\r\n\t\tlong end = System.nanoTime();\r\n\t\tnanos = (end - start);\r\n\t\treturn classes;\r\n\t}\r\n```"}}