[CLOUDSTACK-10408] Fix String.replaceAll() to replace() for bet… (#3275)

* [CLOUDSTACK-10408] Fix String.replaceAll() to replace() for better performance

* improve with replace char but string

Co-authored-by: Rohit Yadav <rohit@apache.org>
This commit is contained in:
Xia Li 2020-01-30 05:06:15 -06:00 committed by GitHub
parent 99ec8a825a
commit f1149bcb09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -109,7 +109,7 @@ public class OnwireClassRegistry {
if (filePath != null) {
// WINDOWS HACK
if (filePath.indexOf("%20") > 0)
filePath = filePath.replaceAll("%20", " ");
filePath = filePath.replace("%20", " ");
if ((filePath.indexOf("!") > 0) && (filePath.indexOf(".jar") > 0)) {
String jarPath = filePath.substring(0, filePath.indexOf("!")).substring(filePath.indexOf(":") + 1);
// WINDOWS HACK

View File

@ -2979,7 +2979,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
final int vnetId = Integer.parseInt(nic.getBrName().replaceFirst("cloudVirBr", ""));
final String pifName = getPif(_guestBridgeName);
final String newBrName = "br" + pifName + "-" + vnetId;
vmDef = vmDef.replaceAll("'" + nic.getBrName() + "'", "'" + newBrName + "'");
vmDef = vmDef.replace("'" + nic.getBrName() + "'", "'" + newBrName + "'");
s_logger.debug("VM bridge name is changed from " + nic.getBrName() + " to " + newBrName);
} catch (final NumberFormatException e) {
continue;

View File

@ -525,7 +525,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
String details = null;
boolean success = false;
String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
String newVolumeName = UUID.randomUUID().toString().replace("-", "");
VmwareContext context = hostService.getServiceContext(cmd);
try {
@ -1053,7 +1053,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
Integer nfsVersion) throws Exception {
String volumeFolder = String.valueOf(volumeId) + "/";
String newVolume = UUID.randomUUID().toString().replaceAll("-", "");
String newVolume = UUID.randomUUID().toString().replace("-", "");
restoreVolumeFromSecStorage(hyperHost, dsMo, newVolume, secStorageUrl, "volumes/" + volumeFolder, exportName, nfsVersion);
return new Pair<String, String>(volumeFolder, newVolume);

View File

@ -2328,9 +2328,9 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
// Block when is not in the list of allowed IPs
if (!NetUtils.isIpInCidrList(loginIpAddress, accessAllowedCidrs.split(","))) {
s_logger.warn("Request by account '" + account.toString() + "' was denied since " + loginIpAddress.toString().replaceAll("/", "") + " does not match " + accessAllowedCidrs);
s_logger.warn("Request by account '" + account.toString() + "' was denied since " + loginIpAddress.toString().replace("/", "") + " does not match " + accessAllowedCidrs);
throw new CloudAuthenticationException("Failed to authenticate user '" + username + "' in domain '" + domain.getPath() + "' from ip "
+ loginIpAddress.toString().replaceAll("/", "") + "; please provide valid credentials");
+ loginIpAddress.toString().replace("/", "") + "; please provide valid credentials");
}
}