This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
src/main/kotlin/com/mapk/fastkfunction/argumentbucket Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,12 @@ class ArgumentBucket(
1616
1717 operator fun set (key : KParameter , value : Any? ): Any? = set(key.index, value)
1818
19- operator fun set (index : Int , value : Any? ): Any? = valueArray[index].apply {
20- if (this == = ABSENT_VALUE ) count++
19+ operator fun set (index : Int , value : Any? ): Any? = if (isInitialized(index))
20+ valueArray[index].apply { valueArray[index] = value }
21+ else {
22+ count++
2123 valueArray[index] = value
24+ null // 値がABSENT_VALUEならnullを返す
2225 }
2326
2427 /* *
@@ -31,11 +34,12 @@ class ArgumentBucket(
3134 * If the specified key is not already associated with a value associates it with the given value and returns
3235 * {@code null}, else returns the current value.
3336 */
34- fun setIfAbsent (index : Int , value : Any? ): Any? = valueArray[index].apply {
35- if (this == = ABSENT_VALUE ) {
36- count++
37- valueArray[index] = value
38- }
37+ fun setIfAbsent (index : Int , value : Any? ): Any? = if (isInitialized(index))
38+ valueArray[index]
39+ else {
40+ count++
41+ valueArray[index] = value
42+ null // 値がABSENT_VALUEならnullを返す
3943 }
4044
4145 private fun isInitialized (index : Int ): Boolean = valueArray[index] != = ABSENT_VALUE
You can’t perform that action at this time.
0 commit comments