Closed lpatiny closed 7 years ago
I don't understand @lpatiny
You could use a structure like:
var result=[]; result.push('my first string'); result.push('my second string'); return result.join(CRLF);
When I did that function I checked and the advise was to use direct concatenation instead of the array push. It was faster at that time.
OK well possible this. We suggested this because the code looks prettier (at our point of view) but I will make a jsperf to check this. For sure the push used to be faster but you are probably right that this changed with time.
I definitely could not find anything concluding about this. A benchmark would help. @targos know something about it?
Yes you are right the concat is faster than the join currently with chrome: https://jsperf.com/test-push-or-concat So you may leave it like that.
Same result on Safari:
https://github.com/cheminfo-js/spectra-data/blob/c3578a2/src/jcampEncoder/JcampCreator.js#L17