This showed up as a bottleneck for gn gen on Android. Refactoring these
out improves gn gen time (avg of 3 trails on my machine) from 2151->1984
BUG=none
Review URL: https://codereview.chromium.org/1909273002
Cr-Original-Commit-Position: refs/heads/master@{#389484}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 95ba4446355ffd95eca68d3c3ba7fc3c2e364b6d