Merge pull request #99 from aeternity/revert-string-compare

Restore old binary and string comparison
This commit is contained in:
Artur Puzio 2021-04-14 11:25:35 +00:00 committed by GitHub
commit 951db9f384
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -325,13 +325,22 @@ lt(?ORD_ORACLE, ?FATE_ORACLE(A), ?FATE_ORACLE(B)) ->
A < B;
lt(?ORD_ORACLE_Q, ?FATE_ORACLE_Q(A), ?FATE_ORACLE_Q(B)) ->
A < B;
% Compare by first different bit. If one is prefix of another than shorter is smaller. (like in Erlang)
lt(?ORD_STRING, ?FATE_STRING(A), ?FATE_STRING(B)) ->
A < B;
compare_bytes(A, B);
lt(?ORD_BYTES, ?FATE_BYTES(A), ?FATE_BYTES(B)) ->
A < B;
compare_bytes(A, B);
lt(?ORD_CONTRACT_BYTEARRAY, ?FATE_CONTRACT_BYTEARRAY(A), ?FATE_CONTRACT_BYTEARRAY(B)) ->
A < B.
compare_bytes(A, B).
% Shorter comes first
% On same length compare by first different bit
compare_bytes(A, B) ->
SizeA = byte_size(A),
SizeB = byte_size(B),
case SizeA - SizeB of
0 -> A < B;
N -> N < 0
end.
tuple_elements_lt(N,_A,_B, N) ->
false;