25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

update existing key instead of dropping an error

SVN Revision: 2398
This commit is contained in:
Evgeniy Khramtsov 2009-07-29 03:40:56 +00:00
parent bf10d1e956
commit a528c62bba

View File

@ -44,7 +44,7 @@ insert(Key, Priority, Value, Tree) ->
insert1(nil, HashKey, Priority, Value) ->
{HashKey, Priority, Value, nil, nil};
insert1({HashKey1, Priority1, Value1, Left, Right},
insert1({HashKey1, Priority1, Value1, Left, Right} = Tree,
HashKey, Priority, Value) ->
if
HashKey < HashKey1 ->
@ -55,8 +55,10 @@ insert1({HashKey1, Priority1, Value1, Left, Right},
heapify({HashKey1, Priority1, Value1,
Left,
insert1(Right, HashKey, Priority, Value)});
Priority == Priority1 ->
{HashKey, Priority, Value, Left, Right};
true ->
erlang:error(key_exists)
insert1(delete_root(Tree), HashKey, Priority, Value)
end.
heapify(nil) ->