--- Begin Message ---
Subject: |
[PATCH] sed: handle the patterns which consist of ^ or $ manually |
Date: |
Wed, 05 Oct 2016 00:18:58 +0900 |
The patterns which consist of only ^ or $ often appear in substitution.
For example, If we change a CSV file into double quoted, will do as
following.
sed 's/^/"/; s/$/"/; s/,/","/g' in >out
First and second substitutions are "the patterns which consist of only ^
or $".
However, regex are not good at them, as regex does not build fastmap for
them, and as all in buffer must be scanned for $. So the patch changes
them into handling manually.
$ yes 12345,67890,12345,67890,12345,67890,12345,67890 | head -1000000 >in
$ time -p env LC_ALL=C sed/sed 's/^/"/; s/$/"/; s/,/","/g' in >/dev/null
real 3.48
user 3.47
sys 0.01
This case was improved by the patch as following.
$ time -p env LC_ALL=C sed/sed 's/^/"/; s/$/"/; s/,/","/g' in >/dev/null
real 1.43
user 1.40
sys 0.02
0001-sed-handle-the-patterns-which-consist-of-or-manually.patch
Description: Text document
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manually |
Date: |
Fri, 4 Nov 2016 21:15:18 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 |
Hello,
On 10/30/2016 07:37 PM, Norihiro Tanaka wrote:
Thanks for adjusting. It seem that it is fine and have no comment. In
addition, all tests are success in my environment.
Thanks for the patches and the review.
Pushed at:
http://git.savannah.gnu.org/cgit/sed.git/commit/?id=7c5b3bed65dd5f4399b35aeffc7152534a29c5d2
http://git.savannah.gnu.org/cgit/sed.git/commit/?id=6dea75e7084eabdd15d8fbbbe05d870eddc98370
I'm marking this as "done".
regards,
- assaf
--- End Message ---