Bug Tracker

Modify

Ticket #6216 (closed enhancement: duplicate)

Opened 3 years ago

Last modified 3 years ago

[Patch] Drop-in replacement for jQuery's trim() function

Reported by: mgruner Owned by:
Priority: Milestone: 1.4.3
Component: misc Version: 1.4.2
Keywords: patch, trim, speed, performance, optimization Cc: marc.nilius@…
Blocking: Blocked by:

Description

Inspired by  http://blog.stevenlevithan.com/archives/faster-trim-javascript, I developed a trim() function that is just a little slower than the current, regexp-replacement based solution in jQuery 1.4.2 for very short strings (< 50 characters). It is, however, MUCH faster for longer and very long strings. Depending on the browser, the speed improvement compared to the current implementation can be several orders of magnitude. Please see the attached patch.

Best regards and wishes for the success of jQuery, Martin Gruner

Attachments

jquery-optimized-trim.patch Download (777 bytes) - added by mgruner 3 years ago.
Optimized trim function for jQuery

Change History

Changed 3 years ago by mgruner

Optimized trim function for jQuery

comment:1 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to duplicate

Duplicate of #2279.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.