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 9093 Details for
Bug 49025
Util.bind(String, String[]) can be optimized a little bit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Uses the char[] instead of Strings
Util.patch (text/plain), 2.87 KB, created by
Michael Fraenkel
on 2004-04-01 09:38:14 EST
(
hide
)
Description:
Uses the char[] instead of Strings
Filename:
MIME Type:
Creator:
Michael Fraenkel
Created:
2004-04-01 09:38:14 EST
Size:
2.87 KB
patch
obsolete
>Index: Util.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java,v >retrieving revision 1.17 >diff -u -r1.17 Util.java >--- Util.java 23 Mar 2004 11:19:24 -0000 1.17 >+++ Util.java 1 Apr 2004 14:20:13 -0000 >@@ -115,24 +115,24 @@ > // for compatibility with MessageFormat which eliminates double quotes in original message > char[] messageWithNoDoubleQuotes = > CharOperation.replace(message.toCharArray(), DOUBLE_QUOTES, SINGLE_QUOTE); >- message = new String(messageWithNoDoubleQuotes); >- if (bindings == null) return message; >+ >+ if (bindings == null) return new String(messageWithNoDoubleQuotes); > >- int length = message.length(); >- int start = -1; >+ int length = messageWithNoDoubleQuotes.length; >+ int start = 0; > int end = length; > StringBuffer output = null; > while (true) { >- if ((end = message.indexOf('{', start)) > -1) { >- if (output == null) output = new StringBuffer(80); >- output.append(message.substring(start + 1, end)); >- if ((start = message.indexOf('}', end)) > -1) { >+ if ((end = CharOperation.indexOf('{', messageWithNoDoubleQuotes, start)) > -1) { >+ if (output == null) output = new StringBuffer(length); >+ 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(message.substring(end + 1, start)); >+ index = Integer.parseInt(argId); > output.append(bindings[index]); > } catch (NumberFormatException nfe) { // could be nested message ID {compiler.name} >- String argId = message.substring(end + 1, start); > boolean done = false; > if (!id.equals(argId)) { > String argMessage = null; >@@ -144,21 +144,22 @@ > // unable to bind argument, ignore (will leave argument in) > } > } >- if (!done) output.append(message.substring(end + 1, start + 1)); >+ if (!done) output.append(messageWithNoDoubleQuotes, end + 1, start - end); > } catch (ArrayIndexOutOfBoundsException e) { > output.append("{missing " + Integer.toString(index) + "}"); //$NON-NLS-2$ //$NON-NLS-1$ > } >+ start++; > } else { >- output.append(message.substring(end, length)); >+ output.append(messageWithNoDoubleQuotes, end, length); > break; > } > } else { >- if (output == null) return message; >- output.append(message.substring(start + 1, length)); >+ if (output == null) return new String(messageWithNoDoubleQuotes); >+ output.append(messageWithNoDoubleQuotes, start, length - start); > break; > } > } >- return output.toString(); >+ return output.toString(); > } > > /**
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 49025
: 9093