Jump to content

Integrated function _FileListToArray improvement?


Tlem
 Share

Recommended Posts

Hello everybody.

In my search of filelist function, I read the File.au3 UDF to see how _FileListToArray was writing.

And in the code I saw that it work directly with array.

I noticed that this approach is slower than using strings and create the array in the end.

So, this is what I noticed on my laptop IBM R60 :

If I use standard _FileListToArray function, the time to do the trip on my @SystemDir is about : 49ms

If I modify the function to use strings, the time decreases to 32ms. :D

Well, 17ms isn't a long time, but my @SystemDir contains only 2497 elements.

For information, I make a test on my @WindowsDir (211 elements), and the difference between time is only of 1ms.

I don't know if it's a good idea to make the modification, but I put it here in case of. :D

Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0)
    Local $hSearch, $sFile, $sFileList, $asFileList[1]
    If Not FileExists($sPath) Then Return SetError(1, 1, "")
    If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
    If (StringMid($sPath, StringLen($sPath), 1) = "\") Then $sPath = StringTrimRight($sPath, 1); needed for Win98 for x:\  root dir
    $hSearch = FileFindFirstFile($sPath & "\" & $sFilter)
    If $hSearch = -1 Then Return SetError(4, 4, "")
    While 1
        $sFile = FileFindNextFile($hSearch)
        If @error Then
            SetError(0)
            ExitLoop
        EndIf
        If $iFlag = 1 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop
        If $iFlag = 2 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop
        $sFileList &= $sFile & "|"
    WEnd
    FileClose($hSearch)
    $asFileList = StringSplit(StringTrimRight($sFileList, 1), "|")
    Return $asFileList
EndFunc  ;==>_FileListToArray

Best Regards.Thierry

Link to comment
Share on other sites

$sFileList &= $sFile & "|"

This statement will do a lot of memory allocation/deallocation so I suggest that for this small improvement we don't change it. :D

In original function there is ReDim $asFileList[uBound($asFileList) + 1] inside loop which does lot of memory allocation/deallocation too.

So developers should consider which of thouse is better.

Link to comment
Share on other sites

You guys are really starting to annoy me with this function. Everybody has an opinion on how this function should behave or should be implemented. Shut up and use what you have. We will never see the end of revisions if you want to tweak it because there will always be somebody better than you who can come along and make it "better".

Link to comment
Share on other sites

You guys are really starting to annoy me with this function. Everybody has an opinion on how this function should behave or should be implemented. Shut up and use what you have. We will never see the end of revisions if you want to tweak it because there will always be somebody better than you who can come along and make it "better".

I'm beginining to think that no UDFs should be included with AutoIt. Let people write their own versions and post them on Example Scripts. This is becoming a never ending problem.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I'm beginining to think that no UDFs should be included with AutoIt. Let people write their own versions and post them on Example Scripts. This is becoming a never ending problem.

People just need to get it through their stupid heads that we dot not have to do everything for them. If they can make modifications to something they need to shut the fuck up and use it. Or post it on the forum if they want to share. A significant amount of community feedback can drive feature change but not one random person saying "hey I can do that better".
Link to comment
Share on other sites

I'm probably still running in PMS mode but to me these posts are becoming a nuisance in general.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Zedna, it's frustrating. People aren't happy they can do something. It must be built-in or at least in a UDF distributed by us. It's absurd how some people can't use code unless we are somehow involved with the distribution of it.

Link to comment
Share on other sites

Probably the need to feel special, the want to have contributed something to such an amazing product. Neither are really bad traits, but agreed it should be done through feedback. That's how I've gotten my UDF's included. Yet they have I believe all been changed/upgraded/fixed but it also was done through the community and tried over and over again before it was included in the actual UDF releases. People don't understand the concept of using the community to test. Not just simply saying I think this is better for this theoretical reason. Prove it. Have more than yourself as proof. Then it may still be declined on the concept of this function is good enough for general consumption.

Oh well...GEOSoft...buddy they make Midol for that PMS stuff you're referencing :D

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Hmmm, but Tlem still points a valid argument imho. The UDFs (and examples; and examples of normal functions as well) are not always the 'most efficient' one's or in some cases even up-to-date. Guys, no offense meant, we all do this in our spare time... just an idea throw into the ring, might a (tightly moderated) UDF/Function Wiki be a... not solution, but improvement? The articles get a release stamp and on new releases creating a .chm file from the wiki should be possible...

Link to comment
Share on other sites

I am really sorry to have started such a reaction while my purpose was to participate like some other.

My knowledge being very limited, so I believed to make by exposing the result of my researches and tests.

I would never have imagined such a rude reaction.

It makes 3 times that I try to participate and 3 times the reaction of developers in summer inequitable.

So in the future, I would keep my reflections for the French forum and as 80 % of the users of this program and forum, I would take without giving (here).

Thus, forgive my cheek, I would see to it not to begin again any more.

Best Regards.Thierry

Link to comment
Share on other sites

Tlem if you know this forum better you would know Valik is quite rude/not friendly/pesimistic almost all the time.

So don't take it personally. It's just the fact: One of the developers is not so friendly as others here.

Now I'm a bit scarred because of my ticket related to _FileListToArray() :-)

http://www.autoitscript.com/trac/autoit/ticket/966

Link to comment
Share on other sites

I would never have imagined such a rude reaction.

Tlem if you know this forum better you would know Valik is quite rude/not friendly/pesimistic almost all the time.

So don't take it personally. It's just the fact: One of the developers is not so friendly as others here.

It's quite well documented as one of the forums only 2 FAQ's-

http://www.autoitscript.com/forum/index.php?showtopic=37739

Do take it personal. Even still, so what...?

Link to comment
Share on other sites

I read well some posts about Valik and about his ego.

But I find surprising the reactions on this forum which it wants a forum of help and of improvement of AutoIt.

I understands whether it is their baby, but if the assistant brought by the members of the forum is systematically subject to pledge, then it is better than we let make these sirs.

I have for my part enough work on the French forum by making what I can to help the members with my little knowledge.

Thus once again, sorry to have disturbed you, I return in furtive mode. :D

Edited by Tlem

Best Regards.Thierry

Link to comment
Share on other sites

I read well some posts about Valik and about his ego.

Then you read posts written by idiots. I. Do. Not. Have. An. Ego.

I really don't know how to make it any more clear than that. Far too many people make an assumption that just because I call somebody stupid or an idiot I am somehow asserting my superiority over everyone. Until the day I state "I am better than everybody" drop the ego bullshit. Stating somebody is stupid does not equate to stating I am better than somebody.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...