Skip to content

Commit aa4a92d

Browse files
committedJul 24, 2017
cc-wrapper/ld-wrapper: Minor speedup in string concatenation
There is still a O(n) pattern match in ld-wrapper, so we should probably rewrite that code to use associative arrays.
1 parent 6669a3b commit aa4a92d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎pkgs/build-support/cc-wrapper/cc-wrapper.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ while [ $n -lt ${#params[*]} ]; do
5555
nonFlagArgs=1
5656
elif [ "$p" = -m32 ]; then
5757
if [ -e @out@/nix-support/dynamic-linker-m32 ]; then
58-
NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)"
58+
NIX_LDFLAGS+=" -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)"
5959
fi
6060
fi
6161
n=$((n + 1))
@@ -111,9 +111,9 @@ fi
111111

112112
if [[ "$isCpp" = 1 ]]; then
113113
if [[ "$cppInclude" = 1 ]]; then
114-
NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE ${NIX_CXXSTDLIB_COMPILE-@default_cxx_stdlib_compile@}"
114+
NIX_CFLAGS_COMPILE+=" ${NIX_CXXSTDLIB_COMPILE-@default_cxx_stdlib_compile@}"
115115
fi
116-
NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK $NIX_CXXSTDLIB_LINK"
116+
NIX_CFLAGS_LINK+=" $NIX_CXXSTDLIB_LINK"
117117
fi
118118

119119
LD=@ldPath@/ld

‎pkgs/build-support/cc-wrapper/ld-wrapper.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ if [ "$NIX_DONT_SET_RPATH" != 1 ]; then
7979
case $libPath in
8080
*\ $path\ *) return 0 ;;
8181
esac
82-
libPath="$libPath $path "
82+
libPath+=" $path "
8383
}
8484

8585
addToRPath() {
@@ -90,12 +90,12 @@ if [ "$NIX_DONT_SET_RPATH" != 1 ]; then
9090
case $rpath in
9191
*\ $1\ *) return 0 ;;
9292
esac
93-
rpath="$rpath $1 "
93+
rpath+=" $1 "
9494
}
9595

9696
libs=""
9797
addToLibs() {
98-
libs="$libs $1"
98+
libs+=" $1"
9999
}
100100

101101
rpath=""

0 commit comments

Comments
 (0)
Please sign in to comment.