Bug Tracker

Opened 9 years ago

Closed 6 years ago

#2279 closed enhancement (fixed)

faster trim

Reported by: phpmyforum Owned by: flesler
Priority: minor Milestone: 1.4.3
Component: core Version: 1.4.2
Keywords: Cc: phpmyforum
Blocked by: Blocking:

Description

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

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

Change History (7)

comment:1 Changed 9 years 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);
},

comment:2 Changed 8 years ago by phpmyforum

No one interested?

comment:3 Changed 8 years ago by flesler

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

comment:4 Changed 8 years ago by flesler

  • Milestone changed from 1.2.3 to 1.3
  • need changed from Review to Patch
  • Owner set to flesler
  • Status changed from new to assigned

comment:5 Changed 8 years ago by flesler

  • Cc phpmyforum added
  • need changed from Patch to Commit

I think I'll add this trim function. We need to do some tests to verify it's a good choice for most situations.

comment:6 Changed 8 years ago by john

After fixing #4037, .trim() is no longer used in jQuery core - FYI.

comment:21 Changed 6 years ago by john

  • Milestone changed from 1.3 to 1.4.3
  • Resolution set to fixed
  • Status changed from assigned to closed
  • Version changed from 1.2.2 to 1.4.2
Note: See TracTickets for help on using tickets.