mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-19 19:34:06 +00:00
extra-cmake-modules: Use associative array to recognize paths
Fixes #99308. Use an associative array to recognize paths that have already been seen by the host path hook. This takes advantage of fast lookup of associative array keys in Bash. The previous solution scanned a linear array, which was accidentally quadratic.
This commit is contained in:
parent
c3805ba16c
commit
194b23e6db
@ -59,23 +59,24 @@ xdgDataSubdirs=( \
|
|||||||
"wallpapers" "applications" "desktop-directories" "mime" "appdata" "dbus-1" \
|
"wallpapers" "applications" "desktop-directories" "mime" "appdata" "dbus-1" \
|
||||||
)
|
)
|
||||||
|
|
||||||
ecmHostPathSeen=( )
|
# ecmHostPathsSeen is an associative array of the paths that have already been
|
||||||
|
# seen by ecmHostPathHook.
|
||||||
|
declare -gA ecmHostPathsSeen
|
||||||
|
|
||||||
ecmUnseenHostPath() {
|
ecmHostPathIsNotSeen() {
|
||||||
for pkg in "${ecmHostPathSeen[@]}"
|
if [[ -n "${ecmHostPathsSeen["$1"]:-}" ]]; then
|
||||||
do
|
# The path has been seen before.
|
||||||
if [ "${pkg:?}" == "$1" ]
|
return 1
|
||||||
then
|
else
|
||||||
return 1
|
# The path has not been seen before.
|
||||||
fi
|
# Now it is seen, so record it.
|
||||||
done
|
ecmHostPathsSeen["$1"]=1
|
||||||
|
return 0
|
||||||
ecmHostPathSeen+=("$1")
|
fi
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ecmHostPathHook() {
|
ecmHostPathHook() {
|
||||||
ecmUnseenHostPath "$1" || return 0
|
ecmHostPathIsNotSeen "$1" || return 0
|
||||||
|
|
||||||
local xdgConfigDir="$1/etc/xdg"
|
local xdgConfigDir="$1/etc/xdg"
|
||||||
if [ -d "$xdgConfigDir" ]
|
if [ -d "$xdgConfigDir" ]
|
||||||
|
Loading…
Reference in New Issue
Block a user