simnova / ownercommunity

MIT License
2 stars 1 forks source link

**suggestion (performance):** Inefficient search for environment variable #138

Open nguyenduy opened 1 month ago

nguyenduy commented 1 month ago
          **suggestion (performance):** Inefficient search for environment variable

Using find and indexOf together can be inefficient. Consider using a single loop or a more efficient method to locate the target line.

let target = -1;
for (let i = 0; i < ENV_VARS.length; i++) {
  if (ENV_VARS[i].match(new RegExp(key))) {
    target = i;
    break;
  }
}

_Originally posted by @sourcery-ai[bot] in https://github.com/simnova/ownercommunity/pull/135#discussion_r1629623988_