From 918a4e76e93c4786dbf37c16355c99e52b4bcd66 Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Wed, 9 Jan 2013 17:22:07 -0800 Subject: Faster ResourceFolderType.getFolderType(String folderName) Change-Id: I7142846efabcb6aadeec2a609ebbc14964120301 --- .../main/java/com/android/resources/ResourceFolderType.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'layoutlib_api/src/main/java') diff --git a/layoutlib_api/src/main/java/com/android/resources/ResourceFolderType.java b/layoutlib_api/src/main/java/com/android/resources/ResourceFolderType.java index 65c1cb3..5a271cf 100644 --- a/layoutlib_api/src/main/java/com/android/resources/ResourceFolderType.java +++ b/layoutlib_api/src/main/java/com/android/resources/ResourceFolderType.java @@ -51,6 +51,7 @@ public enum ResourceFolderType { * @return the enum or null if not found. */ public static ResourceFolderType getTypeByName(String name) { + assert name.indexOf('-') == -1 : name; // use #getFolderType instead for (ResourceFolderType rType : values()) { if (rType.mName.equals(name)) { return rType; @@ -67,10 +68,10 @@ public enum ResourceFolderType { * null if no matching type was found. */ public static ResourceFolderType getFolderType(String folderName) { - // split the name of the folder in segments. - String[] folderSegments = folderName.split(ResourceConstants.RES_QUALIFIER_SEP); - - // get the enum for the resource type. - return getTypeByName(folderSegments[0]); + int index = folderName.indexOf(ResourceConstants.RES_QUALIFIER_SEP); + if (index != -1) { + folderName = folderName.substring(0, index); + } + return getTypeByName(folderName); } } -- cgit v1.1