-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: array
option
#22
Conversation
95444ae
to
796f01d
Compare
This adds flexibility and reduces overhead for the large majority of translations where no replacements are performed.
796f01d
to
3830152
Compare
Prelminary benchmarking on Google Chrome (locally) suggests that simply switching from Array#concat to Array#slice does indeed speed things up quite a bit. (I'm not sure how that rhymes with this performance discusssion but But, regardless, this does not give the ~10x speed boost I'm looking for. :-( |
Switching from Array#slice to starting with a new array and filling it in the loop (i.e. |
By approximately... * 8x for `t(key, repl)` * 3x for `t.arr(key, repl)`
function assemble (parts, replacements, count, debug) { | ||
var result = [].concat(parts) | ||
function assemble (parts, replacements, count, debug, array) { | ||
var result = array ? [parts[0]] : parts[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name is odd... maybe asArray
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.
what about the options property-name? suggestions about that?
This seems to dent performance by 50% on Chrome, but boosts performance by 450% on Firefox.
Please reveiew these changes and merge them if they look good to you. I don't plan to do any more changes for now. |
will look to it tomorrow |
merged and released under 0.4.1 maybe we should do an 1.0 any time soon |
(Adds to #21)
Add
array
option and move "joinResult" check intoassemble
This adds a bit more flexibility and reduces overhead for the large majority of translations where no replacements are performed.
Removing the
.bind()
overhead from the default function probably doesn't hurt either.