Small optimizations? Did you check that idiot checkbox yet?
I started to write the following code:
operationsInTransactions.GetOrAdd(txId, new List<Command>()) .Add(new Command { Key = key, Position = position, Type = CommandType.Put });
But then I realized that in the happy path, I would always allocate a list, even if I don’t need it, and I changed it to this:
operationsInTransactions.GetOrAdd(txId, guid => new List<Command>()) .Add(new Command { Key = key, Position = position, Type = CommandType.Put });
Why am I being stupid?
Hint: It has nothing to do with the stupidity associated with trying to do micro optimizations…

Comments
Comment preview