3 ms·
I disagree, because side effects in an assert would always be a code smell, but placing slow code in there is useful behavior. The line could have easily been:
by reitzensteinm 13y ago
I disagree, because side effects in an assert would always be a code smell, but placing slow code in there is useful behavior. The line could have easily been:
assert EnsureUnique( obj )
Which runs through the program's data structures to ensure that nothing else matches a property of obj in some way.
Hacky, slow, but very useful to keep around if you have a constraint like that. But if you run it in release mode with production sized data sets, it'll slow to a crawl if you don't cut out the entire check.
- gbog 13y agoI wouldn't rely on assert code for this, better say "if dataset is huge don't check".