Tables, use sink val arguments more actively (#15625)

This commit is contained in:
cooldome
2020-10-19 13:13:26 +01:00
committed by GitHub
parent d22ab0fb96
commit 04f8fcfbd0
3 changed files with 30 additions and 29 deletions

View File

@@ -27,7 +27,7 @@ proc rawGetDeep[X, A](t: X, key: A, hc: var Hash): int {.inline.} =
rawGetDeepImpl()
proc rawInsert[X, A, B](t: var X, data: var KeyValuePairSeq[A, B],
key: A, val: B, hc: Hash, h: Hash) =
key: A, val: sink B, hc: Hash, h: Hash) =
rawInsertImpl()
template checkIfInitialized() =

View File

@@ -300,7 +300,7 @@ proc initTable*[A, B](initialSize = defaultInitialSize): Table[A, B] =
b = initTable[char, seq[int]]()
initImpl(result, initialSize)
proc `[]=`*[A, B](t: var Table[A, B], key: A, val: B) =
proc `[]=`*[A, B](t: var Table[A, B], key: A, val: sink B) =
## Inserts a ``(key, value)`` pair into ``t``.
##
## See also:
@@ -484,7 +484,7 @@ proc len*[A, B](t: Table[A, B]): int =
result = t.counter
proc add*[A, B](t: var Table[A, B], key: A, val: B) {.deprecated:
proc add*[A, B](t: var Table[A, B], key: A, val: sink B) {.deprecated:
"Deprecated since v1.4; it was more confusing than useful, use `[]=`".} =
## Puts a new ``(key, value)`` pair into ``t`` even if ``t[key]`` already exists.
##
@@ -839,7 +839,7 @@ proc `[]`*[A, B](t: TableRef[A, B], key: A): var B =
result = t[][key]
proc `[]=`*[A, B](t: TableRef[A, B], key: A, val: B) =
proc `[]=`*[A, B](t: TableRef[A, B], key: A, val: sink B) =
## Inserts a ``(key, value)`` pair into ``t``.
##
## See also:
@@ -968,7 +968,7 @@ proc len*[A, B](t: TableRef[A, B]): int =
result = t.counter
proc add*[A, B](t: TableRef[A, B], key: A, val: B) {.deprecated:
proc add*[A, B](t: TableRef[A, B], key: A, val: sink B) {.deprecated:
"Deprecated since v1.4; it was more confusing than useful, use `[]=`".} =
## Puts a new ``(key, value)`` pair into ``t`` even if ``t[key]`` already exists.
##
@@ -1217,7 +1217,7 @@ proc rawGet[A, B](t: OrderedTable[A, B], key: A, hc: var Hash): int =
proc rawInsert[A, B](t: var OrderedTable[A, B],
data: var OrderedKeyValuePairSeq[A, B],
key: A, val: B, hc: Hash, h: Hash) =
key: A, val: sink B, hc: Hash, h: Hash) =
rawInsertImpl()
data[h].next = -1
if t.first < 0: t.first = h
@@ -1268,7 +1268,7 @@ proc initOrderedTable*[A, B](initialSize = defaultInitialSize): OrderedTable[A,
b = initOrderedTable[char, seq[int]]()
initImpl(result, initialSize)
proc `[]=`*[A, B](t: var OrderedTable[A, B], key: A, val: B) =
proc `[]=`*[A, B](t: var OrderedTable[A, B], key: A, val: sink B) =
## Inserts a ``(key, value)`` pair into ``t``.
##
## See also:
@@ -1455,7 +1455,7 @@ proc len*[A, B](t: OrderedTable[A, B]): int {.inline.} =
result = t.counter
proc add*[A, B](t: var OrderedTable[A, B], key: A, val: B) {.deprecated:
proc add*[A, B](t: var OrderedTable[A, B], key: A, val: sink B) {.deprecated:
"Deprecated since v1.4; it was more confusing than useful, use `[]=`".} =
## Puts a new ``(key, value)`` pair into ``t`` even if ``t[key]`` already exists.
##
@@ -1810,7 +1810,7 @@ proc `[]`*[A, B](t: OrderedTableRef[A, B], key: A): var B =
echo a['z']
result = t[][key]
proc `[]=`*[A, B](t: OrderedTableRef[A, B], key: A, val: B) =
proc `[]=`*[A, B](t: OrderedTableRef[A, B], key: A, val: sink B) =
## Inserts a ``(key, value)`` pair into ``t``.
##
## See also:
@@ -1939,7 +1939,7 @@ proc len*[A, B](t: OrderedTableRef[A, B]): int {.inline.} =
result = t.counter
proc add*[A, B](t: OrderedTableRef[A, B], key: A, val: B) {.deprecated:
proc add*[A, B](t: OrderedTableRef[A, B], key: A, val: sink B) {.deprecated:
"Deprecated since v1.4; it was more confusing than useful, use `[]=`".} =
## Puts a new ``(key, value)`` pair into ``t`` even if ``t[key]`` already exists.
##