mw.ustring.* methods are quite slow, and not needed when trimming with the default charset '\t\r\n\f '.
The implementation I'm submitting runs about 5x~10x times faster. Even the current implementation is fast, but this function is executed a lot of times, so numbers add up.
I'm using the variant 6 from http://lua-users.org/wiki/StringTrim. It is amongst the fastests, has no pitfall, and is a one-liner.