Side navigation
#4036 closed bug (fixed)
Opened February 01, 2009 08:11AM UTC
Closed February 09, 2009 03:35PM UTC
Important performance improvement
Reported by: | dimi | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.3.2 |
Component: | core | Version: | 1.3.1 |
Keywords: | performance | Cc: | dimi@lattica.com |
Blocked by: | Blocking: |
Description
While investigating poor .trim() performance, I discovered that there are only 2 places in core where trim() is used.
One place only needs to test if a string is blank, which can be done a *lot* faster than trimming. As a result this current patch does the following:
- adds a new .blank() function to core that test for empty string.
- uses the new function where appropriate to eliminate the .trim() function.
In my tests with a 660K string I got the following numbers:
.trim() .blank()
FF2/Linux 2353ms 9ms
FF3/Windows 1571ms 8ms
At a very fundamental level .blank() is a much easier function to implement, does not require any memory allocation, and as a result I think it should be part of
the core so others can make use of it. Moreover it only
adds a tiny bit of code, basically just a few bytes.
That is, the minified code is only 47 bytes bigger. When gzipes, that drops to only 18bytes. This is a tiny price to pay for a >100x speedup in some cases.
Read all about it here:
http://zipalong.com/blog/?p=287