Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WOHyperlink, BOZO_AMPERSAND Revisited



There's also a couple of other things you can do to make this a LOT faster.

If you're using JDK 1.5, you can use String.replace(CharSequence, CharSequence) instead of String.replaceAll(String, String).  The reason is that String.replaceAll(String, String) uses regex which is very costly.  In this case the pattern of characters that you're searching for is always going to be the same - "&" - so using regex is serious overkill.

If you're not using JDK 1.5 you might try just using:

url ="" "&").componentsJoinedByString("&");

Even though you're creating a temporary array it might still be faster than using regex.


On Jul 30, 2007, at 12:47 PM, Alex Johnson wrote:

Hi,

Back in Feb 2006, there was a discussion about a bug in WebObjects 5.3.x that caused WOHyperlink to generate doubly-escaped ampersands its URLs (see: <http://lists.apple.com/archives/webobjects-dev/2006/Feb/msg00324.html>). I've been using Daniel Muller's patch <http://lists.apple.com/archives/webobjects-dev/2006/Feb/msg00451.html> ever since.

Recently, I ran up against the performance limitations of this fix: A page with a few hundred links on it takes ~30 seconds to generate, 2/3 of which are spent in the patch code. So, I tweaked the patch to improve its performance, and wanted to share my results (below). Using this version, the page generation is well under one second. The performance improvement comes from in-place manipulation of the response's content, as opposed to replacing the content with a modified copy. This results in a much smaller memory footprint, which greatly reduces the time spent allocating and garbage-collecting throughout the application.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/email@hidden

This email sent to email@hidden

References: 
 >WOHyperlink, BOZO_AMPERSAND Revisited (From: Alex Johnson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.