Modify

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2560 closed Feature Request (Fixed)

UDF - GuiTreeView.au3 - _GUICtrlTreeView_Sort - proposal 2

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

Description

it is continuation to:
http://www.autoitscript.com/trac/autoit/ticket/2554

now _GUICtrlTreeView_Sort contains:

Func _GUICtrlTreeView_Sort($hWnd)
	If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

	Local $iItemCount = _GUICtrlTreeView_GetCount($hWnd)
	If $iItemCount Then
		Local $aTreeView[$iItemCount], $hItem = 0
		For $i = 0 To $iItemCount - 1
			If $i Then
				$hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem, 0, "wparam", "handle", "handle")
			Else
				$hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CHILD, $TVI_ROOT, 0, "wparam", "handle", "handle")
			EndIf
			$aTreeView[$i] = $hItem
		Next
		Local $hChild = 0, $iRecursive = 1
		For $i = 0 To UBound($aTreeView) - 1
			_SendMessage($hWnd, $TVM_SORTCHILDREN, $iRecursive, $aTreeView[$i], 0, "wparam", "handle") ; Sort the items in root
			Do ; Sort all child items
				$hChild = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem, 0, "wparam", "handle", "handle")
				If $hChild Then
					_SendMessage($hWnd, $TVM_SORTCHILDREN, $iRecursive, $hChild, 0, "wparam", "handle")
				EndIf
				$hItem = $hChild
			Until $hItem = 0x00000000
		Next
	EndIf
EndFunc   ;==>_GUICtrlTreeView_Sort

why You use:

For $i = 0 To UBound($aTreeView) - 1

IMHO
easier and faster way:

For $i = 0 To $iItemCount - 1

Attachments (0)

Change History (4)

comment:1 Changed 11 years ago by TicketCleanup

  • Version Other deleted

Automatic ticket cleanup.

comment:2 Changed 11 years ago by BrewManNH

You keep saying these are faster, but you offer no benchmarks to show that they are. How much faster is it doing it this way?

comment:3 Changed 11 years ago by guinness

  • Milestone set to 3.3.9.26
  • Owner set to guinness
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [9269] in version: 3.3.9.26

comment:4 Changed 11 years ago by guinness

I wouldn't say it's faster (not tested) but it's at least smarter as it's one less function call.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain guinness.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.