Skip to content

Commit 98bb877

Browse files
FlyCloudCbobzhang
authored andcommitted
style: rename growAt to grow_at
1 parent 30f91de commit 98bb877

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

builtin/linked_hash_map.mbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct Map[K, V] {
4545
mut size : Int // active key-value pairs count
4646
mut capacity : Int // current capacity
4747
mut capacity_mask : Int // capacity_mask = capacity - 1, used to find idx
48-
mut growAt : Int // threshold that triggers grow
48+
mut grow_at : Int // threshold that triggers grow
4949
mut head : Entry[K, V]? // head of linked list
5050
mut tail : Int // tail of linked list
5151
}
@@ -87,7 +87,7 @@ pub fn Map::new[K, V](capacity~ : Int = 8) -> Map[K, V] {
8787
size: 0,
8888
capacity,
8989
capacity_mask: capacity - 1,
90-
growAt: calc_grow_threshold(capacity),
90+
grow_at: calc_grow_threshold(capacity),
9191
entries: FixedArray::make(capacity, None),
9292
head: None,
9393
tail: -1,
@@ -105,7 +105,7 @@ pub fn Map::from_array[K : Hash + Eq, V](arr : Array[(K, V)]) -> Map[K, V] {
105105
///|
106106
/// Set a key-value pair into the hash map.
107107
pub fn Map::set[K : Hash + Eq, V](self : Map[K, V], key : K, value : V) -> Unit {
108-
if self.size >= self.growAt {
108+
if self.size >= self.grow_at {
109109
self.grow()
110110
}
111111
let hash = key.hash()
@@ -387,7 +387,7 @@ fn Map::grow[K : Hash + Eq, V](self : Map[K, V]) -> Unit {
387387
self.entries = FixedArray::make(new_capacity, None)
388388
self.capacity = new_capacity
389389
self.capacity_mask = new_capacity - 1
390-
self.growAt = calc_grow_threshold(self.capacity)
390+
self.grow_at = calc_grow_threshold(self.capacity)
391391
self.size = 0
392392
self.head = None
393393
self.tail = -1

hashmap/types.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct T[K, V] {
4545
// size of field `entries`, it is redundant but useful for performance
4646
// so we don't need do `self.entries.length()` every time
4747
mut size : Int // active key-value pairs count
48-
// mut growAt : Int // threshold that triggers grow
48+
// mut grow_at : Int // threshold that triggers grow
4949
}
5050
5151
///|

hashset/hashset.mbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn new[K](capacity~ : Int = default_init_capacity) -> T[K] {
2222
{
2323
size: 0,
2424
capacity,
25-
growAt: calc_grow_threshold(capacity),
25+
grow_at: calc_grow_threshold(capacity),
2626
entries: FixedArray::make(capacity, None),
2727
}
2828
}
@@ -53,7 +53,7 @@ pub fn insert[K : Hash + Eq](self : T[K], key : K) -> Unit {
5353
///|
5454
/// Insert a key into hash set.
5555
pub fn add[K : Hash + Eq](self : T[K], key : K) -> Unit {
56-
if self.capacity == 0 || self.size >= self.growAt {
56+
if self.capacity == 0 || self.size >= self.grow_at {
5757
self.grow()
5858
}
5959
let hash = key.hash()
@@ -309,15 +309,15 @@ fn grow[K : Hash + Eq](self : T[K]) -> Unit {
309309
// handle zero capacity
310310
if self.capacity == 0 {
311311
self.capacity = default_init_capacity
312-
self.growAt = calc_grow_threshold(self.capacity)
312+
self.grow_at = calc_grow_threshold(self.capacity)
313313
self.size = 0
314314
self.entries = FixedArray::make(self.capacity, None)
315315
return
316316
}
317317
let old_entries = self.entries
318318
self.entries = FixedArray::make(self.capacity * 2, None)
319319
self.capacity = self.capacity * 2
320-
self.growAt = calc_grow_threshold(self.capacity)
320+
self.grow_at = calc_grow_threshold(self.capacity)
321321
self.size = 0
322322
for i in 0..<old_entries.length() {
323323
if old_entries[i] is Some({ key, .. }) {

hashset/types.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ struct T[K] {
3939
mut entries : FixedArray[Entry[K]?]
4040
mut size : Int // active key count
4141
mut capacity : Int // current capacity
42-
mut growAt : Int // threshold that triggers grow
42+
mut grow_at : Int // threshold that triggers grow
4343
}

set/linked_hash_set.mbt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct Set[K] {
4141
mut size : Int
4242
mut capacity : Int
4343
mut capacity_mask : Int
44-
mut growAt : Int
44+
mut grow_at : Int
4545
mut head : SEntry[K]?
4646
mut tail : SEntry[K]?
4747
}
@@ -58,7 +58,7 @@ pub fn Set::new[K](capacity~ : Int = 8) -> Set[K] {
5858
size: 0,
5959
capacity,
6060
capacity_mask: capacity - 1,
61-
growAt: calc_grow_threshold(capacity),
61+
grow_at: calc_grow_threshold(capacity),
6262
entries: FixedArray::make(capacity, None),
6363
list: FixedArray::make(capacity, { prev: None, next: None }),
6464
head: None,
@@ -86,7 +86,7 @@ pub fn insert[K : Hash + Eq](self : Set[K], key : K) -> Unit {
8686
///|
8787
/// Insert a key into the hash set.if the key exists return false
8888
pub fn add_and_check[K : Hash + Eq](self : Set[K], key : K) -> Bool {
89-
if self.size >= self.growAt {
89+
if self.size >= self.grow_at {
9090
self.grow()
9191
}
9292
let hash = key.hash()
@@ -125,7 +125,7 @@ pub fn add_and_check[K : Hash + Eq](self : Set[K], key : K) -> Bool {
125125
///|
126126
/// Insert a key into the hash set.
127127
pub fn add[K : Hash + Eq](self : Set[K], key : K) -> Unit {
128-
if self.size >= self.growAt {
128+
if self.size >= self.grow_at {
129129
self.grow()
130130
}
131131
let hash = key.hash()
@@ -300,7 +300,7 @@ fn grow[K : Hash + Eq](self : Set[K]) -> Unit {
300300
self.list = FixedArray::make(new_capacity, { prev: None, next: None })
301301
self.capacity = new_capacity
302302
self.capacity_mask = new_capacity - 1
303-
self.growAt = calc_grow_threshold(self.capacity)
303+
self.grow_at = calc_grow_threshold(self.capacity)
304304
self.size = 0
305305
self.head = None
306306
self.tail = None

0 commit comments

Comments
 (0)