Modify

Opened 12 years ago

Closed 12 years ago

#2564 closed Feature Request (Rejected)

UDF - _ArrayInsert - proposal

Reported by: mlipok Owned by:
Milestone: Component: Standard UDFs
Version: Severity: None
Keywords: Cc:

Description

now is

Func _ArrayInsert(ByRef $avArray, $iElement, $vValue = "")
	If Not IsArray($avArray) Then Return SetError(1, 0, 0)
	If UBound($avArray, 0) <> 1 Then Return SetError(2, 0, 0)

	; Check element in array bounds + 1
	If $iElement > UBound($avArray) Then Return SetError(3, 0, 0)

	; Add 1 to the array
	Local $iUBound = UBound($avArray) + 1
	ReDim $avArray[$iUBound]

	; Move all entries over til the specified element
	For $i = $iUBound - 1 To $iElement + 1 Step -1
		$avArray[$i] = $avArray[$i - 1]
	Next

	; Add the value in the specified element
	$avArray[$iElement] = $vValue
	Return $iUBound
EndFunc   ;==>_ArrayInsert

proposal:

change:

	; Check element in array bounds + 1
	If $iElement > UBound($avArray) Then Return SetError(3, 0, 0)

	; Add 1 to the array
	Local $iUBound = UBound($avArray) + 1
	ReDim $avArray[$iUBound]

to

	; Check element in array bounds + 1
	Local $iUBound = UBound($avArray)
	If $iElement > $iUBound Then Return SetError(3, 0, 0)

	; Add 1 to the array
	$iUBound += 1
	ReDim $avArray[$iUBound]

because:
small clarification
and faster (only once uses the UBound($avArray) )

Attachments (0)

Change History (3)

comment:1 by TicketCleanup, 12 years ago

Version: Other

Automatic ticket cleanup.

comment:2 by BrewManNH, 12 years ago

How much faster is it doing it that way?

comment:3 by Jos, 12 years ago

Resolution: Rejected
Status: newclosed

Closing as rejected.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.