Allon Mureinik has uploaded a new change for review. Change subject: core: GuidUtils patterns ......................................................................
core: GuidUtils patterns Use compiled patterns in GuidUtils instead of String.split(separator) since the separators are hardcoded anyway and Pattern.split is faster. Change-Id: I1935c8e6e0c150a6bc7fdc7dc7428b95cb1fce59 Signed-off-by: Allon Mureinik <[email protected]> --- M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/GuidUtils.java 1 file changed, 6 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/37/16437/1 diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/GuidUtils.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/GuidUtils.java index ff9f5c8..027cdc0 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/GuidUtils.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/GuidUtils.java @@ -5,11 +5,15 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; +import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.compat.Guid; public class GuidUtils { + + private static final Pattern GUID_PART_PATTERN = Pattern.compile("-"); + private static final Pattern GUID_LIST_PATTERN = Pattern.compile(","); public static byte[] toByteArray(UUID uuid) { String guidStr = uuid.toString(); @@ -20,7 +24,7 @@ // As GUID may vary in size , the bytes are written to a byte array // output stream // which is kept in - String[] guidParts = guidStr.split("-"); + String[] guidParts = GUID_PART_PATTERN.split(guidStr); if (guidParts == null || guidParts.length == 0) { return null; } @@ -52,8 +56,6 @@ } } - private static final String SEPARATOR = ","; - /** * Gets a string containing multiple <code>Guid</code> values separated by a comma and returns an ArrayList of * <code>Guid</code>. If the String is null/empty returns an empty array. @@ -66,7 +68,7 @@ if (StringUtils.isEmpty(str)) { return new ArrayList<Guid>(); } - return getGuidListFromStringArray(Arrays.asList(str.split(SEPARATOR))); + return getGuidListFromStringArray(Arrays.asList(GUID_LIST_PATTERN.split(str))); } /** -- To view, visit http://gerrit.ovirt.org/16437 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1935c8e6e0c150a6bc7fdc7dc7428b95cb1fce59 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
