[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manu
From: |
Norihiro Tanaka |
Subject: |
bug#24615: [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
- bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manually,
Norihiro Tanaka <=
- bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manually, Assaf Gordon, 2016/10/05
- bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manually, Norihiro Tanaka, 2016/10/06
- bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manually, Assaf Gordon, 2016/10/17
- bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manually, Norihiro Tanaka, 2016/10/18
- bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manually, Assaf Gordon, 2016/10/20
- bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manually, Norihiro Tanaka, 2016/10/21
- bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manually, Assaf Gordon, 2016/10/30
- bug#24615: [PATCH] sed: handle the patterns which consist of ^ or $ manually, Norihiro Tanaka, 2016/10/30