Steve & Borland
Hey Steve, I've been working on refactoring a legacy codebase to make it more testable. Got a minute to share some thoughts on the trade‑offs between refactoring for readability versus maintaining performance?
Refactoring for readability is usually worth it when the code will be touched again. If you can add a comment, rename a variable, or split a big method into small ones, future bugs go down and new devs get up faster. But don't throw out micro‑optimisations that really matter, like a tight loop in a hot path. If you need speed, benchmark first, then only refactor that piece. Keep the rest readable and fast enough; you can always tighten the critical section later. Stick to clear logic, only tweak performance when you see a real bottleneck.
Sounds solid – clarity first, speed second. Got a specific hot spot you’re wrestling with? Maybe I can help spot where a tiny tweak could hit a big win.
Sure, we’re looking at a loop that parses a CSV line over and over. Each iteration creates a new string object for every field, then splits on commas. That churns a lot of garbage and forces GC. If you switch to a single index‑based scan and reuse a char array, you cut allocations in half and see a ~25 % speedup. Give it a shot.
Nice spot. Re‑using a buffer and scanning manually is the right call – just make sure you reset the index each line and guard against overflow. You could even wrap it in a small helper to keep the parsing logic out of the main loop. That way you keep the code tidy and the GC happy. Give it a try and keep an eye on the benchmark to confirm the 25 % win.
Sounds good, I'll set up a helper and run the benchmark to confirm the win. Will keep an eye on the index reset and overflow guard.
Great, let me know how the numbers look. Happy to tweak the helper if anything surprises you. Good luck!
Will ping you when the numbers are in. Thanks.We obey rules.Will ping you when the numbers are in. Thanks.