Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 81249 Details for
Bug 206423
Optimization opportunity in DefaultProblemFactory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix proposal
patch.txt (text/plain), 4.89 KB, created by
Maxime Daniel
on 2007-10-26 05:46:53 EDT
(
hide
)
Description:
Fix proposal
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2007-10-26 05:46:53 EDT
Size:
4.89 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java,v >retrieving revision 1.46 >diff -u -r1.46 DefaultProblemFactory.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java 15 Oct 2007 19:30:44 -0000 1.46 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java 26 Oct 2007 09:42:15 -0000 >@@ -131,28 +131,23 @@ > return getLocalizedMessage(id, 0, problemArguments); > } > public final String getLocalizedMessage(int id, int elaborationId, String[] problemArguments) { >- String message = (String) this.messageTemplates.get(keyFromID(id & IProblem.IgnoreCategoriesMask)); >+ char[] message = ((String) this.messageTemplates.get(keyFromID(id & IProblem.IgnoreCategoriesMask))).toCharArray(); > if (message == null) { > return "Unable to retrieve the error message for problem id: " //$NON-NLS-1$ > + (id & IProblem.IgnoreCategoriesMask) + ". Check compiler resources."; //$NON-NLS-1$ > } > if (elaborationId != 0) { >- String elaboration = (String) this.messageTemplates.get(keyFromID(elaborationId)); >+ char[] elaboration = ((String) this.messageTemplates.get(keyFromID(elaborationId))).toCharArray(); > if (elaboration == null) { > return "Unable to retrieve the error message elaboration for elaboration id: " //$NON-NLS-1$ > + elaborationId + ". Check compiler resources."; //$NON-NLS-1$ > } >- // make the substitution. String.replaceAll(String,String) cannot be used since it is >- // defined only in 1.4 >- message = new String(CharOperation.replace( >- message.toCharArray(), >- FIRST_ARGUMENT, >- elaboration.toCharArray())); >+ message = CharOperation.replace(message, FIRST_ARGUMENT, elaboration); > } > > // for compatibility with MessageFormat which eliminates double quotes in original message > char[] messageWithNoDoubleQuotes = >- CharOperation.replace(message.toCharArray(), DOUBLE_QUOTES, SINGLE_QUOTE); >+ CharOperation.replace(message, DOUBLE_QUOTES, SINGLE_QUOTE); > > if (problemArguments == null) return new String(messageWithNoDoubleQuotes); > >@@ -169,18 +164,15 @@ > if (output == null) output = new StringBuffer(length+problemArguments.length*20); > output.append(messageWithNoDoubleQuotes, start, end - start); > if ((start = CharOperation.indexOf('}', messageWithNoDoubleQuotes, end + 1)) > -1) { >- int index = -1; >- String argId = new String(messageWithNoDoubleQuotes, end + 1, start - end - 1); > try { >- index = Integer.parseInt(argId); >- output.append(problemArguments[index]); >+ output.append(problemArguments[CharOperation.parseInt(messageWithNoDoubleQuotes, end + 1, start - end - 1)]); > } catch (NumberFormatException nfe) { > output.append(messageWithNoDoubleQuotes, end + 1, start - end); > } catch (ArrayIndexOutOfBoundsException e) { > return "Cannot bind message for problem (id: " //$NON-NLS-1$ > + (id & IProblem.IgnoreCategoriesMask) > + ") \"" //$NON-NLS-1$ >- + message >+ + new String(message) > + "\" with arguments: {" //$NON-NLS-1$ > + Util.toString(problemArguments) > +"}"; //$NON-NLS-1$ >Index: compiler/org/eclipse/jdt/core/compiler/CharOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CharOperation.java,v >retrieving revision 1.80 >diff -u -r1.80 CharOperation.java >--- compiler/org/eclipse/jdt/core/compiler/CharOperation.java 2 Oct 2007 17:12:02 -0000 1.80 >+++ compiler/org/eclipse/jdt/core/compiler/CharOperation.java 26 Oct 2007 09:42:15 -0000 >@@ -2845,7 +2845,28 @@ > count++; > return count; > } >- >+/** >+ * Return the int value represented by the designated subpart of array. The >+ * calculation of the result for single-digit positive integers is optimized in >+ * time. >+ * @param array the array within which the int value is to be parsed >+ * @param start first character of the int value in array >+ * @param length length of the int value in array >+ * @return the int value of a subpart of array >+ * @throws NumberFormatException if the designated subpart of array does not >+ * parse to an int >+ */ >+public static final int parseInt(char[] array, int start, int length) throws NumberFormatException { >+ if (length == 1) { >+ int result = array[start] - '0'; >+ if (result < 0 || result > 9) { >+ throw new NumberFormatException("invalid digit"); //$NON-NLS-1$ >+ } >+ return result; >+ } else { >+ return Integer.parseInt(new String(array, start, length)); >+ } >+} > /** > * Answers true if the given name starts with the given prefix, false otherwise. > * The comparison is case sensitive.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 206423
:
81249
|
81581