Modify

Opened 10 years ago

Closed 10 years ago

#759 closed Bug (Fixed)

_GUICtrlListView_GetItemTextString() --> BIG speed optimize

Reported by: Zedna Owned by: Jpm
Milestone: 3.3.1.0 Component: Standard UDFs
Version: 3.2.12.1 Severity: None
Keywords: Cc:

Description

$iSelected = _GUICtrlListView_GetNextItem($hWnd)
should be before FOR NEXT loop and not inside.

When I need to get text of all listview items then this function will be called many times: number of rows * number of columns!

original:

Func _GUICtrlListView_GetItemTextString($hWnd, $iItem = -1)
	If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)
	Local $sRow = "", $SeparatorChar = Opt('GUIDataSeparatorChar')
	If $iItem <> -1 Then ; get row
		For $x = 0 To _GUICtrlListView_GetColumnCount($hWnd) - 1
			$sRow &= _GUICtrlListView_GetItemText($hWnd, $iItem, $x) & $SeparatorChar
		Next
		Return StringTrimRight($sRow, 1)
	Else ; get current row selected
		For $x = 0 To _GUICtrlListView_GetColumnCount($hWnd) - 1
			$sRow &= _GUICtrlListView_GetItemText($hWnd, _GUICtrlListView_GetNextItem($hWnd), $x) & $SeparatorChar
		Next
		Return StringTrimRight($sRow, 1)
	EndIf
EndFunc   ;==>_GUICtrlListView_GetItemTextString

optimized:

Func _GUICtrlListView_GetItemTextString($hWnd, $iItem = -1)
	If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)
	Local $sRow = "", $SeparatorChar = Opt('GUIDataSeparatorChar')
	If $iItem <> -1 Then ; get row
		For $x = 0 To _GUICtrlListView_GetColumnCount($hWnd) - 1
			$sRow &= _GUICtrlListView_GetItemText($hWnd, $iItem, $x) & $SeparatorChar
		Next
		Return StringTrimRight($sRow, 1)
	Else ; get current row selected
		$iSelected = _GUICtrlListView_GetNextItem($hWnd)
		For $x = 0 To _GUICtrlListView_GetColumnCount($hWnd) - 1
			$sRow &= _GUICtrlListView_GetItemText($hWnd, $iSelected, $x) & $SeparatorChar
		Next
		Return StringTrimRight($sRow, 1)
	EndIf
EndFunc   ;==>_GUICtrlListView_GetItemTextString

Attachments (0)

Change History (2)

comment:1 Changed 10 years ago by Jpm

even smaller with

Func _GUICtrlListView_GetItemTextString($hWnd, $iItem = -1)
	If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)
	Local $sRow = "", $SeparatorChar = Opt('GUIDataSeparatorChar')
	If $iItem = -1 Then
                $iSelected = _GUICtrlListView_GetNextItem($hWnd) ; get current row selected
        Else
                $iSelected = $iItem  ; get row
        Endif
	For $x = 0 To _GUICtrlListView_GetColumnCount($hWnd) - 1
		$sRow &= _GUICtrlListView_GetItemText($hWnd, $iSelected, $x) & $SeparatorChar
	Next
	Return StringTrimRight($sRow, 1)
EndFunc   ;==>_GUICtrlListView_GetItemTextString

comment:2 Changed 10 years ago by Jpm

  • Milestone set to 3.3.1.0
  • Owner changed from Gary to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed in version: 3.3.1.0

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 Jpm.
Author


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

 
Note: See TracTickets for help on using tickets.