disccomp wrote:
> Please see this excellent breakdown of this function on cross-browser
> performance to better understand the available solutions.
> http://blog.stevenlevithan.com/archives/faster-trim-javascript
Awesome analysis!

I wonder if trim12 might be improved by avoiding calling slice if there 
is no trailing white space:

function trim12 (str) {
        var     str = str.replace(/^\s\s*/, ''),
                ws = /\s/,
                i = str.length,
                len = i;
        while (ws.test(str.charAt(--i)));
        return i + 1 < len ? str.slice(0, i + 1) : str;

Also, you did not say it explicitly, but are you saying that /\s/.test() 
is faster than whitespace.indexOf() ?

- Ken

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to