mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-03 05:44:10 -08:00
C: fix overlapping file names
This commit is contained in:
parent
eab7ef0a2e
commit
31f91bc63c
|
@ -32,32 +32,34 @@ public class ShorteningFileNameProvider implements FileNameProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String fileName(String className) {
|
public String fileName(String className) {
|
||||||
return unique(shorten(nameProvider.fileName(className)));
|
return process(nameProvider.fileName(className));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String fileName(ValueType type) {
|
public String fileName(ValueType type) {
|
||||||
return unique(shorten(nameProvider.fileName(type)));
|
return process(nameProvider.fileName(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String escapeName(String name) {
|
public String escapeName(String name) {
|
||||||
return unique(shorten(nameProvider.escapeName(name)));
|
return process(nameProvider.escapeName(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String process(String name) {
|
||||||
|
return names.computeIfAbsent(name, n -> unique(shorten(n)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String unique(String name) {
|
private String unique(String name) {
|
||||||
return names.computeIfAbsent(name, n -> {
|
if (usedNames.add(name)) {
|
||||||
if (usedNames.add(n)) {
|
return name;
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
int suffix = 1;
|
int suffix = 1;
|
||||||
while (true) {
|
while (true) {
|
||||||
String candidate = n + "_" + suffix++;
|
String candidate = name + "_" + suffix++;
|
||||||
if (usedNames.add(candidate)) {
|
if (usedNames.add(candidate)) {
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String shorten(String name) {
|
private static String shorten(String name) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user