microsoft / vscode-l10n

MIT License
64 stars 12 forks source link

Possible optimization: skip regex replacement when there are no replacement arguments #135

Closed jruales closed 1 year ago

jruales commented 1 year ago

Looking at the file l10n/src/main.ts it seems like it's always running a regex replace, even if the call to t() didn't receive any replacement args. I'm thinking that there could be an optimization where the program just returns the unchanged string in such cases, instead of running a no-op regex replacement.

TylerLeonhardt commented 1 year ago

Yeah good point. A simple check like:

Object.keys(values).length

would be a minor optimization. Any interest in submitting a PR? This is a pretty quick fix.

jruales commented 1 year ago

@TylerLeonhardt I've created the PR. Do you know if this would need to be done in vscode.l10n.t() as well? Where's the code for that?

jruales commented 1 year ago

I've created another PR for that too. See: https://github.com/microsoft/vscode/pull/194854