2 ms·
Ten times? Foo. Maybe double. But that's still twice the cost, for only a potential win. Better check first that it helps somebody write better/more correct/qu
by JoeAltmaier 2y ago
Ten times? Foo. Maybe double.
But that's still twice the cost, for only a potential win. Better check first that it helps somebody write better/more correct/quicker code.
E.g. we wanted to change our text-screen video driver to allow a full-screen overlay (many years ago). The programmer assigned the task was changing the text-blit code to know about certain lines on the screen that were going to be the 'nested' window, which could be 'up' and masking a subset of the window below, or 'down' and the full screen should be displayed as normal.
He'd been hacking away, changing every case in the code to 'know about' the particular window that was planned. Pulling his hair out, getting nowhere.
I suggested a simple indirection buffer, where each line of a virtual display was pointed to indirectly. To put the subwindow 'up' or 'down' you just pointed those lines of the main screen to a buffer, and pointed the lines of the subwindow to the hardware store for video text.
All his changes folded into 'access display indirectly'. Trivial. Then the up/down code became a loop that changed a pointer and copied some text.
That was actually an abstraction, and actually much shorter/faster/simpler to understand and change.
Later we could change the window dimensions, have multiple windows etc with no change to the video driver.