Skip to content

Instantly share code, notes, and snippets.

@KFlash
Created December 30, 2019 04:00
Show Gist options
  • Save KFlash/8dd32bf7e07f19a9c0ae3dc968415509 to your computer and use it in GitHub Desktop.
Save KFlash/8dd32bf7e07f19a9c0ae3dc968415509 to your computer and use it in GitHub Desktop.
practice
// 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