Skip to content
Myr

Improve performance of `--nth` option (#90 contd.)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 2d00abc · Browse files · 1 file+6 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−3 removed

  • other:+6 added−3 removed

1 file+6 added−3 removed

modified:fzf+6 added-3 removed
1104 unmodified lines
1105 begin1106 unless @delim1107 # AWK default1108 prefix_length = str.index(/\S/) || 01109 tokens = str.strip.scan(/\S+\s*/) rescue []1109 tokens = str.scan(/\S+\s*/) rescue []1110 else1111 prefix_length = 01112 tokens = str.scan(@delim) rescue []1113 end1114 @nth.map { |n|1115 (part = tokens[n]) &&1115 if n.begin == 0 && n.end == -11116 [prefix_length, tokens.join]1117 elsif part = tokens[n]1118 [prefix_length + (tokens[0...(n.begin)] || []).join.length,1117 part.join.sub(/\s+$/, '')]1119 part.join]1120 end1121 }.compact1122 end1123 end1124
147 unmodified lines