I recently rewrote some bash code to replace
for subdir in $names do for parent in $(parent_of $dir) do [ -d $parent/$subdir ] && … done done
parents_of $dir | append_subdirs $names | is_dir | xargs …
I recently rewrote some bash code to replace
with I expected a modest speed improvement (due to not calculating the parents of a dir repeatedly), but was surprised to see it was twice as fast!