In commit 4454085 we added a Case 0 to Arr_IndexRaw() for when l > u…
|
Select Case n |
|
Case 0: Assign v, a() |
|
Case 1: Assign v, a(i(l)) |
…along with a Case Else:
|
Case Else: Assign v, a() |
|
End Select |
This addresses any situation where the bounds are discoordinated, and throws the native error for trying to access an array without supplying any indices: a().
However, it also adds one extra Case every time we access an array. I suspect we would be just as safe removing Case 0…
|
Select Case n |
|
Case 1: Assign v, a(i(l)) |
…and simply deferring to the Case Else. Unless I misinterpret the Select Case statement, we (linearly) gain a little performance for all other situations, by skipping the irrelevant Case 0.
Only when the array is uninitialized do we have l > u, and we must traverse all sixty cases from Case 1 through Case 60, before we reach the Case Else. But Arr_Index() already validates against this situation…
|
' Short-circuit for uninitialized array. |
|
Dim aRnk As Long: aRnk = Arr_Rank(arr) |
|
If aRnk = 0 Then Debug.Print "ERROR: The array must be initialized." |
…as does Arr_IndexRaw():
|
' Short circuit for uninitialized array. |
|
Dim r As Long: r = Arr_Rank(x) |
|
If r = 0 Then Debug.Print "ERROR: Uninitialized array." |
In commit 4454085 we added a
Case 0toArr_IndexRaw()for whenl > u…Idx/src/Idx.bas
Lines 200 to 202 in f05dcb3
…along with a
Case Else:Idx/src/Idx.bas
Lines 262 to 263 in f05dcb3
This addresses any situation where the bounds are discoordinated, and throws the native error for trying to access an array without supplying any indices:
a().However, it also adds one extra
Caseevery time we access an array. I suspect we would be just as safe removingCase 0…Idx/src/Idx.bas
Lines 215 to 216 in 9cf1fec
…and simply deferring to the
Case Else. Unless I misinterpret theSelect Casestatement, we (linearly) gain a little performance for all other situations, by skipping the irrelevantCase 0.Only when the array is uninitialized do we have
l > u, and we must traverse all sixty cases fromCase 1throughCase 60, before we reach theCase Else. ButArr_Index()already validates against this situation…Idx/src/Idx.bas
Lines 124 to 126 in f05dcb3
…as does
Arr_IndexRaw():Idx/src/Idx.bas
Lines 161 to 163 in f05dcb3