Re: [PATCH 06/20] scripts/make-erofs.sh: Avoid unneeded calls to mkdir

Alyssa Ross
2025-09-08T08:39:40Z

[-- Attachment #1: Type: text/plain, Size: 923 bytes --]

Demi Marie Obenour <demiobenour@gmail.com> writes:

> Don't call it if the target directory already exists.
>
> Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
> ---
> scripts/make-erofs.sh | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/make-erofs.sh b/scripts/make-erofs.sh
> index 93cb3245f409b24c24be05e9307a1b2e12c867fe..66abd1f388524c19cd3a1113415892d0d72e3f82 100755
> --- a/scripts/make-erofs.sh
> +++ b/scripts/make-erofs.sh
> @@ -86,12 +86,12 @@ while read -r arg1; do
> # Create the parent directory if it doesn't already
> # exist.
> parent=${arg2%/*}
> + if [ ! -d "$root/$parent" ]; then
> + mkdir -p -- "$root/$parent"
> + fi
> ;;
> - (*)
> - parent=.
> - ;;
> + (*) :;; # parent $root which definitely exists
> esac
> - mkdir -p -- "$root/$parent"
> cp -RT -- "$arg1" "$root/$arg2"
> done

Is there a non-negligible speed increase?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]