Modify

Opened 17 years ago

Closed 17 years ago

#759 closed Bug (Fixed)

_GUICtrlListView_GetItemTextString() --> BIG speed optimize

Reported by: Zedna Owned by: J-Paul Mesnage
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 by J-Paul Mesnage, 17 years ago

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 by J-Paul Mesnage, 17 years ago

Milestone: 3.3.1.0
Owner: changed from Gary to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed in version: 3.3.1.0

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


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