further unrolling of string parsing states and elimination of when
guards
This commit is contained in:
parent
8e2d7a0253
commit
4b3fa9b903
2 changed files with 16 additions and 13 deletions
|
@ -647,16 +647,16 @@ count(<<127, Rest/binary>>, N, Config) ->
|
|||
count(<<_, Rest/binary>>, N, Config=#config{dirty_strings=true}) ->
|
||||
count(Rest, N + 1, Config);
|
||||
count(<<_/utf8, _/binary>>, N, #config{uescape=true}) -> N;
|
||||
count(<<X/utf8, Rest/binary>>, N, Config) when X < 16#800 ->
|
||||
count(Rest, N + 2, Config);
|
||||
%% u+2028
|
||||
count(<<226, 128, 168, _/binary>>, N, _) -> N;
|
||||
%% u+2029
|
||||
count(<<226, 128, 169, _/binary>>, N, _) -> N;
|
||||
count(<<X/utf8, Rest/binary>>, N, Config) when X < 16#10000 ->
|
||||
count(Rest, N + 3, Config);
|
||||
count(<<_/utf8, Rest/binary>>, N, Config) ->
|
||||
count(Rest, N + 4, Config);
|
||||
count(<<X/utf8, Rest/binary>>, N, Config) ->
|
||||
case X of
|
||||
X when X < 16#800 -> count(Rest, N + 2, Config);
|
||||
X when X < 16#10000 -> count(Rest, N + 3, Config);
|
||||
_ -> count(Rest, N + 4, Config)
|
||||
end;
|
||||
count(_, N, _) -> N.
|
||||
|
||||
|
||||
|
|
|
@ -451,13 +451,16 @@ count(<<126, Rest/binary>>, N, Config) ->
|
|||
count(<<127, Rest/binary>>, N, Config) ->
|
||||
count(Rest, N + 1, Config);
|
||||
count(<<_/utf8, _/binary>>, N, #config{uescape=true}) -> N;
|
||||
count(<<X/utf8, _/binary>>, N, _) when X == 16#2028; X == 16#2029 -> N;
|
||||
count(<<X/utf8, Rest/binary>>, N, Config) when X < 16#800 ->
|
||||
count(Rest, N + 2, Config);
|
||||
count(<<X/utf8, Rest/binary>>, N, Config) when X < 16#10000 ->
|
||||
count(Rest, N + 3, Config);
|
||||
count(<<_/utf8, Rest/binary>>, N, Config) ->
|
||||
count(Rest, N + 4, Config);
|
||||
%% u+2028
|
||||
count(<<226, 128, 168, _/binary>>, N, _) -> N;
|
||||
%% u+2029
|
||||
count(<<226, 128, 169, _/binary>>, N, _) -> N;
|
||||
count(<<X/utf8, Rest/binary>>, N, Config) ->
|
||||
case X of
|
||||
X when X < 16#800 -> count(Rest, N + 2, Config);
|
||||
X when X < 16#10000 -> count(Rest, N + 3, Config);
|
||||
_ -> count(Rest, N + 4, Config)
|
||||
end;
|
||||
count(<<_, _/binary>>, N, _) -> N.
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue