Move caching of OptionDefinitions to be static, and remove uncached extractions of OptionDefinitions.

We already had caching of OptionsData objects, for a list of OptionsBases, but repeated the reflective work for the same OptionsBase if it appeared in different lists. Now that the @Option-annotation specific state is isolated to the OptionDefinition object, this can be trivially cached by OptionsBase.

There are a few additional convenient side effects to this change. This should slightly decrease the memory use of the OptionsParser, since it already cached this map per options-base, and now only requires a single copy. It also means that parts of the code base that needed details of an option's definition no longer need to either obtain an option definition themselves or need access to an OptionsData object, which should be private to the OptionsParser anyway.

PiperOrigin-RevId: 167158902
GitOrigin-RevId: 987f09f0cf3c5bf2fc5157c20fe0f7979978a40b
Change-Id: I5ceeb8e2b12215f5702a8731b9a94b97bd48792a
5 files changed
tree: 3cdfa4f83826e527ca7c052c0284887001d0eabd
  1. java/