diff mbox series

[FFmpeg-devel,1/2] compat/cuda/ptx2c: remove shell loop

Message ID 20200523040122.83476-1-rcombs@rcombs.me
State New
Headers show
Series [FFmpeg-devel,1/2] compat/cuda/ptx2c: remove shell loop | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Ridley Combs May 23, 2020, 4:01 a.m. UTC
This improves build times dramatically
---
 compat/cuda/ptx2c.sh | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Carl Eugen Hoyos May 23, 2020, 11:47 a.m. UTC | #1
Am Sa., 23. Mai 2020 um 06:01 Uhr schrieb rcombs <rcombs@rcombs.me>:
>
> This improves build times dramatically
> ---
>  compat/cuda/ptx2c.sh | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/compat/cuda/ptx2c.sh b/compat/cuda/ptx2c.sh
> index 0750e7a3b7..435a9b4b6c 100755
> --- a/compat/cuda/ptx2c.sh
> +++ b/compat/cuda/ptx2c.sh
> @@ -27,10 +27,8 @@ IN="$2"
>  NAME="$(basename "$IN" | sed 's/\..*//')"
>
>  printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
> -while IFS= read -r LINE
> -do
> -    printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed -e 's/\r//g' -e 's/["\\]/\\&/g')" >> "$OUT"
> -done < "$IN"
> -printf ";\n" >> "$OUT"
> +echo >> "$OUT"

> +sed -e 's/\r//g' -e 's/["\\]/\\&/g' -e 's/^[[:space:]]*/\t"/' -e 's/$/\\n"/' < "$IN" >> "$OUT"

Is there a reason why you did not merge the two patches?

Carl Eugen
Ridley Combs May 23, 2020, 6:05 p.m. UTC | #2
> On May 23, 2020, at 06:47, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> 
> Am Sa., 23. Mai 2020 um 06:01 Uhr schrieb rcombs <rcombs@rcombs.me>:
>> 
>> This improves build times dramatically
>> ---
>> compat/cuda/ptx2c.sh | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>> 
>> diff --git a/compat/cuda/ptx2c.sh b/compat/cuda/ptx2c.sh
>> index 0750e7a3b7..435a9b4b6c 100755
>> --- a/compat/cuda/ptx2c.sh
>> +++ b/compat/cuda/ptx2c.sh
>> @@ -27,10 +27,8 @@ IN="$2"
>> NAME="$(basename "$IN" | sed 's/\..*//')"
>> 
>> printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
>> -while IFS= read -r LINE
>> -do
>> -    printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed -e 's/\r//g' -e 's/["\\]/\\&/g')" >> "$OUT"
>> -done < "$IN"
>> -printf ";\n" >> "$OUT"
>> +echo >> "$OUT"
> 
>> +sed -e 's/\r//g' -e 's/["\\]/\\&/g' -e 's/^[[:space:]]*/\t"/' -e 's/$/\\n"/' < "$IN" >> "$OUT"
> 
> Is there a reason why you did not merge the two patches?
> 
> Carl Eugen

Just that I wrote them several months apart from one another, and they conceptually serve different purposes (perf in one, compatibility in the other).

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Carl Eugen Hoyos May 23, 2020, 10:43 p.m. UTC | #3
Am Sa., 23. Mai 2020 um 20:13 Uhr schrieb Ridley Combs <rcombs@rcombs.me>:
>
> > On May 23, 2020, at 06:47, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >
> > Am Sa., 23. Mai 2020 um 06:01 Uhr schrieb rcombs <rcombs@rcombs.me>:
> >>
> >> This improves build times dramatically
> >> ---
> >> compat/cuda/ptx2c.sh | 8 +++-----
> >> 1 file changed, 3 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/compat/cuda/ptx2c.sh b/compat/cuda/ptx2c.sh
> >> index 0750e7a3b7..435a9b4b6c 100755
> >> --- a/compat/cuda/ptx2c.sh
> >> +++ b/compat/cuda/ptx2c.sh
> >> @@ -27,10 +27,8 @@ IN="$2"
> >> NAME="$(basename "$IN" | sed 's/\..*//')"
> >>
> >> printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
> >> -while IFS= read -r LINE
> >> -do
> >> -    printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed -e 's/\r//g' -e 's/["\\]/\\&/g')" >> "$OUT"
> >> -done < "$IN"
> >> -printf ";\n" >> "$OUT"
> >> +echo >> "$OUT"
> >
> >> +sed -e 's/\r//g' -e 's/["\\]/\\&/g' -e 's/^[[:space:]]*/\t"/' -e 's/$/\\n"/' < "$IN" >> "$OUT"
> >
> > Is there a reason why you did not merge the two patches?
> >
> Just that I wrote them several months apart from one another, and they
> conceptually serve different purposes (perf in one, compatibility in the other).

Please merge them.

Carl Eugen
diff mbox series

Patch

diff --git a/compat/cuda/ptx2c.sh b/compat/cuda/ptx2c.sh
index 0750e7a3b7..435a9b4b6c 100755
--- a/compat/cuda/ptx2c.sh
+++ b/compat/cuda/ptx2c.sh
@@ -27,10 +27,8 @@  IN="$2"
 NAME="$(basename "$IN" | sed 's/\..*//')"
 
 printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
-while IFS= read -r LINE
-do
-    printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed -e 's/\r//g' -e 's/["\\]/\\&/g')" >> "$OUT"
-done < "$IN"
-printf ";\n" >> "$OUT"
+echo >> "$OUT"
+sed -e 's/\r//g' -e 's/["\\]/\\&/g' -e 's/^[[:space:]]*/\t"/' -e 's/$/\\n"/' < "$IN" >> "$OUT"
+echo ";" >> "$OUT"
 
 exit 0