git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Use perl instead of tac

From
JSJörg Sommer <joerg@alea.gnuu.de>
Date
Apr 28, 2008, 15:15 UTC
Message-ID
<slrng1bqhb.25r.joerg@alea.gnuu.de>
In-Reply-To
<86k5iib0g9.fsf@blue.stonehenge.com>
Hallo Randal,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
Show 7 quoted lines
>>>>>> "Jörg" == Jörg Sommer <joerg@alea.gnuu.de> writes:
>
> Jörg> What about using a shell function and a *big* variable or an intermediate
> Jörg> file?
>
> What makes you think that's any more faster or efficient than calling Perl
> at this point?

Nothing. My intention was not the speed, but the dependency on Perl. But your are right. Except from the point that my suggestion is broken, it's *much* slower:

% time dash -c 'while IFS= read -r line; do rev="$line $rev"; done; printf "%s" "$rev"' < gitk-git/gitk-wish DN dash -c < gitk-git/gitk-wish > /dev/null 2> /dev/null 17,89s user 2,68s system 96% cpu 21,352 total

% time tac < gitk-git/gitk-wish DN tac < gitk-git/gitk-wish > /dev/null 2> /dev/null 0,01s user 0,01s system 91% cpu 0,017 total

% time perl -e 'print reverse <>' < gitk-git/gitk-wish DN perl -e 'print reverse <>' < gitk-git/gitk-wish > /dev/null 2> /dev/null 0,07s user 0,01s system 59% cpu 0,141 total

But I doubt this hurts, because we don't have such a big input.

% wc -l git.c 390 git.c

% time dash -c 'while IFS= read -r line; do rev="$line $rev"; done; printf "%s" "$rev"' < git.c DN dash -c < git.c > /dev/null 2> /dev/null 0,04s user 0,04s system 62% cpu 0,115 total

And what about something like this: 'tac || rev || perl …'
Bye, Jörg.
-- 
Was der Bauer nicht kennt, das frisst er nicht. Würde der Städter kennen,
was er frisst, er würde umgehend Bauer werden.
                                                       Oliver Hassencamp
Previous: Johannes SchindelinNext: Avery Pennarun
Message 15 of 30 in “Use of tac in git-rebase--interactive”
  1. Brian GernhardtApr 27, 2008
  2. Jeff KingApr 27, 2008
  3. Use perl instead of tacBrian Gernhardt, Apr 27, 2008
  4. rebase--interactive: Replace unportable 'tac' by a sed script.Johannes Sixt, Apr 28, 2008
  5. Junio C HamanoApr 28, 2008
  6. Paolo BonziniApr 28, 2008
  7. Jeff KingApr 28, 2008
  8. Andreas EricssonApr 28, 2008
  9. Jörg SommerApr 28, 2008
  10. Randal L. SchwartzApr 28, 2008
  11. David SymondsApr 28, 2008
  12. Paolo BonziniApr 28, 2008
  13. Brian GernhardtApr 28, 2008
  14. Johannes SchindelinApr 28, 2008
  15. Jörg SommerApr 28, 2008
  16. Avery PennarunApr 28, 2008
  17. Matthieu MoyApr 28, 2008
  18. Brian GernhardtApr 28, 2008
  19. Brian GernhardtApr 28, 2008
  20. Jörg SommerApr 30, 2008
  21. Jörg SommerApr 30, 2008
  22. Brian GernhardtApr 30, 2008
  23. Brian GernhardtApr 30, 2008
  24. Jörg SommerMay 4, 2008
  25. Brian GernhardtMay 6, 2008
  26. Johannes SchindelinApr 28, 2008
  27. Brian GernhardtApr 28, 2008
  28. Johannes SchindelinApr 28, 2008
  29. しらいしななこApr 27, 2008
  30. Junio C HamanoApr 30, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.