This project is archived and is in readonly mode.

#39 ✓invalid
Thomas Aylott

Faster Trim Method

Reported by Thomas Aylott | May 28th, 2008 @ 10:05 AM | in 2.0 (closed)

Originally posted on Trac by Rendez

Original Trac Ticket

Description

trim() and consequently clean() String methods may gain speed just by changing the regular expression:

trim: function(){
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

Between older and new regex there's a difference of 46ms, it may be worthwhile.

see: http://blog.stevenlevithan.com/a...

Trac Attachments

Trac Comments

Comments and changes to this ticket

  • Jan Kassens

    Jan Kassens August 31st, 2008 @ 07:17 PM

    • State changed from “new” to “invalid”
    • Tag set to core, enhancement, trivial

    the tests in the blog post are tested on a string with 27,600 chars, not really a real world scenario.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages