Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's another advantage to using filters in pipelines: each part of the pipeline runs in parallel!

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
with

  parents_of $dir | append_subdirs $names | is_dir | xargs …
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!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: