Skip to content

Commit 50cf311

Browse files
committed
Reuse package name utility function
1 parent f006085 commit 50cf311

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

src/main/java/io/smallrye/modules/desc/ModuleDescriptor.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,21 +212,18 @@ private Map<String, PackageInfo> searchPackages(final Resource dir,
212212
} else {
213213
String pathName = child.pathName();
214214
if (pathName.endsWith(".class")) {
215-
int idx = pathName.lastIndexOf('/');
216-
if (idx != -1) {
217-
String pn = pathName.substring(0, idx).replace('/', '.');
218-
if (found.add(pn)) {
219-
PackageInfo existing = map.get(pn);
220-
PackageInfo update = packageFunction.apply(pn, existing);
221-
if (update == null || update.equals(existing)) {
222-
// skip it
223-
continue;
224-
}
225-
if (map == packages) {
226-
map = new HashMap<>(packages);
227-
}
228-
map.put(pn, update);
215+
String pn = Util.resourcePackageName(pathName);
216+
if (!pn.isEmpty() && found.add(pn)) {
217+
PackageInfo existing = map.get(pn);
218+
PackageInfo update = packageFunction.apply(pn, existing);
219+
if (update == null || update.equals(existing)) {
220+
// skip it
221+
continue;
222+
}
223+
if (map == packages) {
224+
map = new HashMap<>(packages);
229225
}
226+
map.put(pn.intern(), update);
230227
}
231228
}
232229
}

0 commit comments

Comments
 (0)