Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2556c6

Browse files
authored
Merge pull request #3519 from forki/height
Do not calc map height twice
2 parents44fa027 +6d413f1 commitd2556c6

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

‎src/utils/TaggedCollections.fs‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,12 @@ namespace Internal.Utilities.Collections.Tagged
724724
#endif
725725
| MapNode(_,_,_,_,h)-> h
726726

727-
letisEmpty m=
727+
letinlineisEmpty m=
728728
match mwith
729729
| MapEmpty->true
730730
|_->false
731731

732-
letmk l k v r=
732+
letinlinemk l k v r=
733733
#if ONE
734734
match l,rwith
735735
| MapEmpty,MapEmpty-> MapOne(k,v)
@@ -741,8 +741,9 @@ namespace Internal.Utilities.Collections.Tagged
741741
MapNode(k,v,l,r,m+1)
742742

743743
letrebalance t1 k v t2=
744-
lett1h= height t1
745-
if height t2> t1h+2then// right is heavier than left
744+
lett1h= height t1
745+
lett2h= height t2
746+
if t2h> t1h+2then// right is heavier than left
746747
match t2with
747748
| MapNode(t2k,t2v,t2l,t2r,_)->
748749
// one of the nodes must have height > height t1 + 1
@@ -755,8 +756,7 @@ namespace Internal.Utilities.Collections.Tagged
755756
mk(mk t1 k v t2l) t2k t2v t2r
756757
|_-> failwith"rebalance"
757758
else
758-
lett2h= height t2
759-
if t1h> t2h+2then// left is heavier than right
759+
if t1h> t2h+2then// left is heavier than right
760760
match t1with
761761
| MapNode(t1k,t1v,t1l,t1r,_)->
762762
// one of the nodes must have height > height t2 + 1
@@ -1097,7 +1097,8 @@ namespace Internal.Utilities.Collections.Tagged
10971097
[<Sealed>]
10981098
typeinternalMap<'Key,'T,'ComparerTag>when'ComparerTag:>IComparer<'Key>( comparer:IComparer<'Key>, tree:MapTree<'Key,'T>)=
10991099

1100-
static letrefresh(m:Map<_,_,'ComparerTag>)t= Map<_,_,'ComparerTag>(comparer=m.Comparer, tree=t)
1100+
static letrefresh(m:Map<_,_,'ComparerTag>)t=
1101+
Map<_,_,'ComparerTag>(comparer=m.Comparer, tree=t)
11011102

11021103
members.Tree= tree
11031104
members.Comparer:IComparer<'Key>= comparer

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp