Cleanup: Pass std::string arguments by reference (this avoids making
unnecessary copies) and label them const, per the
Google style guide.

Tested:
  $ ./bootstrap_test.sh all

--
Change-Id: I17636703cf43283f71b9b913c130a51065bd896b
Reviewed-on: https://bazel-review.googlesource.com/1350
MOS_MIGRATED_REVID=93876332
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index edc9f2c..42dcda0 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -1325,7 +1325,7 @@
 // Figure out the base directories based on embedded data, username, cwd, etc.
 // Sets globals->options.install_base, globals->options.output_base,
 // globals->lock_file, globals->jvm_log_file.
-static void ComputeBaseDirectories(const string self_path) {
+static void ComputeBaseDirectories(const string &self_path) {
   // Only start a server when in a workspace because otherwise we won't do more
   // than emit a help message.
   if (!BlazeStartupOptions::InWorkspace(globals->workspace)) {
diff --git a/src/main/cpp/blaze_util.cc b/src/main/cpp/blaze_util.cc
index f50023c..d9f593e 100644
--- a/src/main/cpp/blaze_util.cc
+++ b/src/main/cpp/blaze_util.cc
@@ -63,7 +63,7 @@
 // If called from working directory "/bar":
 //   MakeAbsolute("foo") --> "/bar/foo"
 //   MakeAbsolute("/foo") ---> "/foo"
-string MakeAbsolute(string path) {
+string MakeAbsolute(const string &path) {
   // Check if path is already absolute.
   if (path.empty() || path[0] == '/') {
     return path;
@@ -241,7 +241,7 @@
 // Replace the current process with the given program in the given working
 // directory, using the given argument vector.
 // This function does not return on success.
-void ExecuteProgram(string exe, const vector<string>& args_vector) {
+void ExecuteProgram(const string& exe, const vector<string>& args_vector) {
   if (VerboseLogging()) {
     string dbg;
     for (const auto& s : args_vector) {
@@ -278,8 +278,9 @@
   ExecuteProgram(args[0], args);
 }
 
-const char* GetUnaryOption(const char *arg, const char *next_arg,
-                                  const char *key) {
+const char* GetUnaryOption(const char *arg,
+                           const char *next_arg,
+                           const char *key) {
   const char *value = blaze_util::var_strprefix(arg, key);
   if (value == NULL) {
     return NULL;
@@ -343,7 +344,7 @@
   return "";
 }
 
-string GetJvmVersion(string java_exe) {
+string GetJvmVersion(const string &java_exe) {
   vector<string> args;
   args.push_back("java");
   args.push_back("-version");
@@ -370,7 +371,8 @@
   }
 }
 
-bool CheckJavaVersionIsAtLeast(string jvm_version, string version_spec) {
+bool CheckJavaVersionIsAtLeast(const string &jvm_version,
+                               const string &version_spec) {
   vector<string> jvm_version_vect = blaze_util::Split(jvm_version, '.');
   vector<string> version_spec_vect = blaze_util::Split(version_spec, '.');
   int i;
diff --git a/src/main/cpp/blaze_util.h b/src/main/cpp/blaze_util.h
index b135a96..3870ce3 100644
--- a/src/main/cpp/blaze_util.h
+++ b/src/main/cpp/blaze_util.h
@@ -36,11 +36,11 @@
 // If called from working directory "/bar":
 //   MakeAbsolute("foo") --> "/bar/foo"
 //   MakeAbsolute("/foo") ---> "/foo"
-string MakeAbsolute(string path);
+string MakeAbsolute(const string &path);
 
 // mkdir -p path. All newly created directories use the given mode.
 // Returns -1 on failure, sets errno.
-int MakeDirectories(const string& path, mode_t mode);
+int MakeDirectories(const string &path, mode_t mode);
 
 // Replaces 'content' with contents of file 'filename'.
 // Returns false on error.
@@ -69,7 +69,7 @@
 void AddJVMSpecificArguments(const string &host_javabase,
                              std::vector<string> *result);
 
-void ExecuteProgram(string exe, const std::vector<string>& args_vector);
+void ExecuteProgram(const string &exe, const std::vector<string> &args_vector);
 
 void ReExecute(const string &executable, int argc, const char *argv[]);
 
@@ -101,14 +101,15 @@
 // is supposed to output a string in the form '.*version ".*".*'. This method
 // will return the part in between the two quote or the empty string on failure
 // to match the good string.
-string GetJvmVersion(string java_exe);
+string GetJvmVersion(const string &java_exe);
 
 // Returns true iff jvm_version is at least the version specified by
 // version_spec.
 // jvm_version is supposed to be a string specifying a java runtime version
 // as specified by the JSR-56 appendix A. version_spec is supposed to be a
 // version is the format [0-9]+(.[1-9]+)*.
-bool CheckJavaVersionIsAtLeast(string jvm_version, string version_spec);
+bool CheckJavaVersionIsAtLeast(const string &jvm_version,
+                               const string &version_spec);
 
 }  // namespace blaze
 
diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc
index d33554b..9500cf4 100644
--- a/src/main/cpp/option_processor.cc
+++ b/src/main/cpp/option_processor.cc
@@ -41,7 +41,6 @@
   option_ = option;
 }
 
-
 OptionProcessor::RcFile::RcFile(const string& filename, int index) {
   filename_ = filename;
   index_ = index;
@@ -58,7 +57,8 @@
 }
 
 blaze_exit_code::ExitCode OptionProcessor::RcFile::Parse(
-    string filename, const int index,
+    const string& filename,
+    const int index,
     vector<RcFile>* rcfiles,
     map<string, vector<RcOption> >* rcoptions,
     list<string>* import_stack,
diff --git a/src/main/cpp/option_processor.h b/src/main/cpp/option_processor.h
index 9bc7a38..15724e8 100644
--- a/src/main/cpp/option_processor.h
+++ b/src/main/cpp/option_processor.h
@@ -94,7 +94,8 @@
     const int Index() const { return index_; }
 
    private:
-    static blaze_exit_code::ExitCode Parse(string filename, const int index,
+    static blaze_exit_code::ExitCode Parse(const string& filename,
+                                           const int index,
                                            std::vector<RcFile>* rcfiles,
                                            std::map<string,
                                            std::vector<RcOption> >* rcoptions,