Update src/leveled_pmem.erl

Simple change to check for presence of objetc in list before adding it:

```Head check took 124416 microseconds checking list of length 5000

Head check took 130114 microseconds checking list of length 5000

Check for presence of repeated objects

Head check took 1725 microseconds checking list of length 5```
This commit is contained in:
Martin Sumner 2018-12-10 12:01:11 +00:00
parent e73f48a18b
commit b38d845c3a

View file

@ -200,7 +200,12 @@ merge_trees(StartKey, EndKey, TreeList, LevelMinus1) ->
find_pos(<<>>, _Hash, PosList, _SlotID) ->
PosList;
find_pos(<<1:1/integer, Hash:23/integer, T/binary>>, Hash, PosList, SlotID) ->
find_pos(T, Hash, PosList ++ [SlotID], SlotID);
case lists:member(SlotID, PosList) of
true ->
find_pos(T, Hash, PosList, SlotID);
false ->
find_pos(T, Hash, PosList ++ [SlotID], SlotID)
end;
find_pos(<<1:1/integer, _Miss:23/integer, T/binary>>, Hash, PosList, SlotID) ->
find_pos(T, Hash, PosList, SlotID);
find_pos(<<0:1/integer, NxtSlot:7/integer, T/binary>>, Hash, PosList, _SlotID) ->