Speed up Xcode path substitution by avoiding per-argument subprocess (#696)
diff --git a/lib/apple_support.bzl b/lib/apple_support.bzl
index 3796004..a3508db 100644
--- a/lib/apple_support.bzl
+++ b/lib/apple_support.bzl
@@ -179,26 +179,15 @@
 
 set -eu
 
-# SYNOPSIS
-#   Rewrites any Bazel placeholder strings in the given argument string,
-#   echoing the result.
-#
-# USAGE
-#   rewrite_argument <argument>
-function rewrite_argument {
-  ARG="$1"
-  ARG="${ARG//__BAZEL_XCODE_DEVELOPER_DIR__/$DEVELOPER_DIR}"
-  ARG="${ARG//__BAZEL_XCODE_SDKROOT__/$SDKROOT}"
-  echo "$ARG"
-}
-
 TOOLNAME="$1"
 shift
 
 ARGS=()
 
 for ARG in "$@" ; do
-  ARGS+=("$(rewrite_argument "$ARG")")
+  ARG="${ARG//__BAZEL_XCODE_DEVELOPER_DIR__/$DEVELOPER_DIR}"
+  ARG="${ARG//__BAZEL_XCODE_SDKROOT__/$SDKROOT}"
+  ARGS+=("$ARG")
 done
 
 exec "$TOOLNAME" "${ARGS[@]}"
@@ -209,19 +198,6 @@
 set -eu
 
 # SYNOPSIS
-#   Rewrites any Bazel placeholder strings in the given argument string,
-#   echoing the result.
-#
-# USAGE
-#   rewrite_argument <argument>
-function rewrite_argument {
-  ARG="$1"
-  ARG="${ARG//__BAZEL_XCODE_DEVELOPER_DIR__/$DEVELOPER_DIR}"
-  ARG="${ARG//__BAZEL_XCODE_SDKROOT__/$SDKROOT}"
-  echo "$ARG"
-}
-
-# SYNOPSIS
 #   Rewrites any Bazel placeholder strings in the given params file, if any.
 #   If there were no substitutions to be made, the original path is echoed back
 #   out; otherwise, this function echoes the path to a temporary file
@@ -281,7 +257,8 @@
     ARG="@$NEWFILE"
     ;;
   *)
-    ARG=$(rewrite_argument "$ARG")
+    ARG="${ARG//__BAZEL_XCODE_DEVELOPER_DIR__/$DEVELOPER_DIR}"
+    ARG="${ARG//__BAZEL_XCODE_SDKROOT__/$SDKROOT}"
     ;;
   esac
   ARGS+=("$ARG")