further unrolling of string parsing states and elimination of when

guards
This commit is contained in:
alisdair sullivan 2014-12-07 19:12:43 -08:00
parent 8e2d7a0253
commit 4b3fa9b903
2 changed files with 16 additions and 13 deletions

View file

@ -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.