You're right, I've never imagined a system that would need to be flipping the mode back and forth. In that case, adoptInstance is quicker, but since we've had to special-case it, its certainly more "complex" and the fact that swapping out an objects class is not a common thing to do in Smalltalk, it seems fair to say its less legible. That's not an objection, though. :)
On Tue, May 31, 2016 at 11:12 AM, Levente Uzonyi leves@caesar.elte.hu wrote:
On Tue, 31 May 2016, Chris Muller wrote:
It's an optimization, so it's not mandatory. Of course it's nice to have,
An optimization of what? Execution speed? Is it such an optimization that any human could ever possibly notice? Setting the mode of a stream, really?
I suspect that you expect one to set mode at most once per stream, which is not always the case. I could easily give you an artificial benchmark showing 30x speedup, but that would make no sense. It's a library method and as such, why not make it quicker when possible?
I like most of your optimizations but, IMO, this one is so infinitesmal, I don't think it exceeds the cost of the decreased legibility / complexity..
Please explain the legibility / complexity part.
Levente