Bug Tracker

Ticket #2279 (assigned enhancement)

Opened 7 months ago

Last modified 2 months ago

faster trim

Reported by: phpmyforum Assigned to: flesler (accepted)
Type: enhancement Priority: minor
Milestone: 1.3 Component: core
Version: 1.2.2 Keywords:
Cc: Needs: Patch

Description

Maybe everyone had read this already... I think jQuery would really benefit from this:

http://blog.stevenlevithan.com/archives/faster-trim-javascript

Attachments

jquery-4763-trim.diff (457 bytes) - added by DarkRyder 6 months ago.
Diff against rev 2763.

Change History

Changed 6 months ago by DarkRyder

Seconded. Specifically, I'd suggest the following version, which is Steve's trim12 function with the null-value fix from bug 1395:

trim: function( text ) {
	var text = (text || "").replace(/^\s\s*/, ''),
	    ws = /\s/,
	    i = text.length;
	while ( ws.test(text.charAt(--i)) ){}
	return text.slice(0, i + 1);
},

Changed 6 months ago by DarkRyder

Diff against rev 2763.

Changed 4 months ago by phpmyforum

No one interested?

Changed 4 months ago by flesler

I actually proposed one, and I think this trim12 is pretty much mine :)

Changed 2 months ago by flesler

  • need changed from Review to Patch
  • status changed from new to assigned
  • owner set to flesler
  • milestone changed from 1.2.3 to 1.3
Note: See TracTickets for help on using tickets.