3 ms·
Go actually doesn't have any other way to clear a map! Which, actually, is brilliant design! Now, I can find all map clearings with one operation. (I need to i
by stcredzero 8y ago
Go actually doesn't have any other way to clear a map!
Which, actually, is brilliant design! Now, I can find all map clearings with one operation. (I need to implement that syntactic search/rewrite tool I miss from Smalltalk.)
- apta 8y agoHow is not having map.clear() a brilliant design?
- stcredzero 8y agoIn a large project, you'll have all ways of doing any given thing represented in a code base. Reducing that number down to 1 means that searching for all occurrences is reduced to 1 operation. If you are working on a large project, searching for usages/senders/occurrences is one of the most common tasks that you do. In fact, using escape analysis of the same kind used for "Extract Method" refactorings, you can even catch clearing interspersed with other code in the for-range loop. A 50%+ reduction in programmer work is nothing to be sneezed at.