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:
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.