5 ms·tl;dr: str.count($\) was 1.5x faster compared to str.lines.count and didn't allocate additional memory.by ilyazub 3y agotl;dr: str.count($\) was 1.5x faster compared to str.lines.count and didn't allocate additional memory.