2002/css-validator/org/w3c/css/util InvalidParamException.java,1.7,1.8

Update of /sources/public/2002/css-validator/org/w3c/css/util
In directory hutz:/tmp/cvs-serv15822

Modified Files:
	InvalidParamException.java 
Log Message:
small optim


Index: InvalidParamException.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/util/InvalidParamException.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- InvalidParamException.java	10 Dec 2008 15:25:52 -0000	1.7
+++ InvalidParamException.java	24 Feb 2009 22:57:37 -0000	1.8
@@ -57,20 +57,26 @@
     
     private static String processError(String error, Object args, ApplContext ac) {
     	if (args instanceof String[]) {
+	    String[] s_args = (String[]) args;
+	    StringBuilder sb = new StringBuilder();
 	    String str = null;
-	    
+
 	    if (error != null) {
 		str = ac.getMsg().getErrorString(error);
 	    }
-	    if (str == null)
+	    if (str == null) {
 		return "can't find the error message for " + error;
-	    else {
+	    } else {
 		// replace all parameters
+		String[] msg_parts = str.split("%s");
 		int j = 0;
-		for (int i = 0; (i = str.indexOf("%s")) >= 0 && j < ((String[]) args).length; ) {
-		    str = str.substring(0, i) + ((String[]) args)[j++] + str.substring(i+2);
+		for (int i = 0; i< msg_parts.length; i++) {
+		    sb.append(msg_parts[i]);
+		    if (j < s_args.length) {
+			sb.append(s_args[j++]);
+		    }
 		}
-		return str;
+		return sb.toString();
 	    }
     	} else {
 	    return processError(error, args.toString(), "", ac);

Received on Tuesday, 24 February 2009 22:57:50 UTC