When creating URL objects we have a small optimization in place that avoids initializing Locale on bootstrap:
static String toLowerCase(String protocol) {
if (protocol.equals("jrt") || protocol.equals("file") || protocol.equals("jar")) {
return protocol;
} else {
return protocol.toLowerCase(Locale.ROOT);
}
}
This could be improved in two ways:
- move it to sun.net.util.URLUtil to facilitate reuse
- return "jrt", "file" or "jar" respectively to get canonicalization of the protocol string for free, saving memory for any URL we hold on to for an extended time
static String toLowerCase(String protocol) {
if (protocol.equals("jrt") || protocol.equals("file") || protocol.equals("jar")) {
return protocol;
} else {
return protocol.toLowerCase(Locale.ROOT);
}
}
This could be improved in two ways:
- move it to sun.net.util.URLUtil to facilitate reuse
- return "jrt", "file" or "jar" respectively to get canonicalization of the protocol string for free, saving memory for any URL we hold on to for an extended time