Modify

Opened 12 years ago

Closed 12 years ago

#2561 closed Feature Request (Rejected)

UDF - _ArrayPermute - proposal

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

Description

now:

Func _ArrayPermute(ByRef $avArray, $sDelim = "")
	If Not IsArray($avArray) Then Return SetError(1, 0, 0)
	If UBound($avArray, 0) <> 1 Then Return SetError(2, 0, 0)
	Local $iSize = UBound($avArray), $iFactorial = 1, $aIdx[$iSize], $aResult[1], $iCount = 1

	If UBound($avArray) Then
		For $i = 0 To $iSize - 1
			$aIdx[$i] = $i
		Next
		For $i = $iSize To 1 Step -1
			$iFactorial *= $i
		Next
		ReDim $aResult[$iFactorial + 1]
		$aResult[0] = $iFactorial
		__Array_ExeterInternal($avArray, 0, $iSize, $sDelim, $aIdx, $aResult, $iCount)
	Else
		$aResult[0] = 0
	EndIf
	Return $aResult
EndFunc   ;==>_ArrayPermute

proposal
change:

If UBound($avArray) Then

to:

If $iSize Then

because: faster and cleaner

Attachments (0)

Change History (4)

comment:1 by Jos, 12 years ago

Have you actually tested this and have proof as I believe the evaluation in the For statement is only done one time at its start so Ubound() is only done one time?

Jos

comment:2 by TicketCleanup, 12 years ago

Version: Other

Automatic ticket cleanup.

comment:3 by mlipok, 12 years ago

I have a few solutions that operate very strongly, with variables of type array.
The script is running slowly because a lot of data processing.
I can not identify changes in performance.
Overall, I look at the features available, and looking for possible improvements.

In this case, I think I was a little gone too far.

comment:4 by Jos, 12 years ago

Resolution: Rejected
Status: newclosed

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.