Re:Designing a better strcpy
by kevin_thibedeau on Sunday June 20, 2021 @01:09AM
(#27567274)
> the extra 8 bytes and the cycles saved (if any) don't matter
You wouldn't last in embedded development with that sort of attitude. When you're nearly out of RAM you can't afford to waste overhead of fat strings.
I was using Turbo Basic, Turbo Pascal, Turbo C++ (with C++ collections), and Clipper on MS-DOS, with 640 KB of memory.
It was just fine, then there are those that nowadays even toy with C++17 on C64.
“Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”
https://www.youtube.com/watch?v=zBkNBP00wJE
Really, unless we are talking about PIC and AVRs with like 4KB, we are optimizing for the wrong target.
You can't afford to waste cycles on O(n) strlen either.
Not every embedded system is memory constrained these days.
In the common case, the extra 8 bytes and the cycles saved (if any) don't matter — and are not worth the sacrifice of making it harder to program correctly.