globalizejs/globalize

Code cleanup: Drop runtime `[].slice.call( arguments, 0 )`?

Open

#485 geöffnet am 22. Aug. 2015

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (645 Forks)batch import
help wantedquick change

Repository-Metriken

Stars
 (4.759 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

In the normal modules, arguments is cloned using slice (e.g., https://github.com/jquery/globalize/blob/fix-398-runtime/src/message.js#L64), so it's not subject to further changes (e.g., https://github.com/jquery/globalize/blob/fix-398-runtime/src/message.js#L70). Therefore, on each respective runtime module the same procedure happens again (e.g., https://github.com/jquery/globalize/blob/fix-398-runtime/src/message-runtime.js#L15) or the hash output would be different (given it's based on JSON.stringify and stringifying arguments has different output than stringifying an Array).

It should be possible to avoid all that slice thing (and instead use arguments directly in the hashing function) if no method (like the one exemplified above) changes any passed variable. Therefore, arguments would never change, therefore there would be no need to clone them.

The goal of this issue is to investigate if this proposed change would simplify the code and is worth making.

Contributor Guide