News for hackers. Stuff that matters.
Re:Anti-If: The missing patterns (2016) by Someone on Thursday June 28, 2018 @11:41AM (#17417801)
IMO, both examples are bad because they search for the key twice.

That’s inefficient and, worse, introduces a concurrency bug. The cached value may expire between the check using ‘contains’ and the call to ‘get’.

A good API would have something akin to C#’s TryGet (https://msdn.microsoft.com/en-us/library/bb347013(v=vs.110)....).

There are no comments on this comment yet.