Reduce the state kept in OptionProcessor.
Make the list of rc files a local variable as it need not be a class
attribute, and drop the unused rcoptions_ field.
This is a trivial refactoring and the remaining code is still too
confusing. It'd be worth splitting OptionProcessor in two pieces:
OptionProcessor to exclusively keep the virtual ParseOptions method
and no state, and a new ParsedOptions type to act as the immutable
return value of ParseOptions. This would decouple all state
mutations.
RELNOTES: None.
PiperOrigin-RevId: 193557347
diff --git a/src/main/cpp/option_processor.h b/src/main/cpp/option_processor.h
index 736c004..2ae1798 100644
--- a/src/main/cpp/option_processor.h
+++ b/src/main/cpp/option_processor.h
@@ -16,7 +16,6 @@
#define BAZEL_SRC_MAIN_CPP_OPTION_PROCESSOR_H_
#include <list>
-#include <map>
#include <memory>
#include <string>
#include <vector>
@@ -135,15 +134,9 @@
std::string* user_blazerc_file, std::string* error) const;
private:
- blaze_exit_code::ExitCode ParseStartupOptions(std::string* error);
-
- // The list of parsed rc files, this field is initialized by ParseOptions.
- std::vector<std::unique_ptr<RcFile>> rc_files_;
-
- // A map representing the flags parsed from the bazelrc files.
- // A key is a command (e.g. 'build', 'startup') and its value is an ordered
- // list of RcOptions.
- std::map<std::string, std::vector<RcOption>> rcoptions_;
+ blaze_exit_code::ExitCode ParseStartupOptions(
+ const std::vector<std::unique_ptr<RcFile>>& rc_files,
+ std::string* error);
// An ordered list of command args that contain information about the
// execution environment and the flags passed via the bazelrc files.