perf(various): Avoid putIfAbsent

This code was originally authored by @mhevery in the
DirectiveInjector change.