Jump to content
Chimaera

Is there any differences with these? one seems faster to me

Recommended Posts

Chimaera

I recently was helped with some code by melba like this

For $removeloop = UBound($aRemoveArray) - 1 To 1 Step -1 
    $search = _ArraySearch($aList, $aRemoveArray[$removeloop])
    $test = _ArrayDelete($aList, $search)
    Sleep(10)
Next

but ive got this working as well which i had on another script

For $removeloop = 1 To UBound($aRemoveArray) - 1
        Local $iIndex = _ArraySearch($aList, $aRemoveArray[$removeloop]) ; Look for the index of the item
        If $iIndex <> -1 Then ; If found...
            _ArrayDelete($aList, $iIndex) ; ...then remove it
        EndIf
    Next

but the second one doesnt wait as long as the first?

Why is this the case?

Share this post


Link to post
Share on other sites
Melba23

Chimaera,

If you have a lot of items in $aRemoveArray then all those Sleep(10) commands will add up to a significant delay.

And although I cannot imagine it being a factor here, in the first snippet I would also question the need to run through the array backwards. You need to do this if you are deleting elements of the same array that you use for the count, but that is not the case here. 

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Chimaera

Thats what happens when you stare at code too long.... you miss the obvious because your looking for the complicated...

The 1st array eg was from you and i couldnt work out why it was like that :)

Share this post


Link to post
Share on other sites
Melba23

Chimaera,

A fresh pair of eyes is always useful.

When I originally posted, I probably made the general point without looking too closely at the specific case - my apologies if that was indeed what happened.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×