Created
December 30, 2019 04:00
-
-
Save KFlash/8dd32bf7e07f19a9c0ae3dc968415509 to your computer and use it in GitHub Desktop.
practice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bad practice | |
1) function x() { while (i < length) { let x = i; ... } } | |
2) while (i < length) { x.y.z[i] = 'hello'; } | |
// God practice | |
1) Do the loop outside func body. It's a slow wrapper anyways :) | |
// Define 'x' outside the loop, else you need to reallocate memory for it | |
// on each run and assign | |
let x = 0; while (i < length) { x = i; ... } | |
2) The 2 first members are static, so define them outside the loop | |
let _static = x.y.z | |
while (i < length) { _static[i] = 'hello'; } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment