Article View: borland.public.cppbuilder.nativeapi
Article #1000Re: find .exe's
From: Bob Gonder
Date: Tue, 30 Oct 2007 21:14
Date: Tue, 30 Oct 2007 21:14
29 lines
2115 bytes
2115 bytes
mataus wrote: >Can anyone help me make this fast? 1) You use AnsiString which is often slower than plain cstrings. 2) You Add() to Memo->Lines. This is probably slow. 3) You manually check _every_ file to see if it is a folder or an exe. 4) You ProcessMessages() way too often. 5) You are passed the path which you then mess with and later ExtractFilePath(sPath) to get back to the passed path. For #1, Don't be so quick to use AnsiString all over the place. Use a char array[MAX_PATH+1] for local strings. For #2, Append() might be faster. BeginUpdate / EndUpdate around the entire process might speed up the Memo. For #3, I would break it into two sections. First section, FindFirst/Next would specify FILE_ATTRIBUTE_DIRECTORY in the search attributes. (Handle all folders first, quickly.) Second section, new FindFirst/Next would specify \*.exe so you only get those files instead of _every_ file. For #4, eliminate it from the loop. If you find you really do need it, then put a counter on it so it only executes every ~50 times through the loop. For #5, you could copy the passed path to a local char[] and ensure it has the terminating \. Then use that to build the other strings.
Technical Details
Message-ID:
<p26fi3plb2vipoubanvr19vuefl5j2l132@4ax.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4727891b$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,52a2861022dfbb0b X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: find .exe's Date: Tue, 30 Oct 2007 14:14:07 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <p26fi3plb2vipoubanvr19vuefl5j2l132@4ax.com> References: <4727891b$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 69.69.84.21 X-Trace: newsgroups.borland.com 1193778847 69.69.84.21 (30 Oct 2007 14:14:07 -0700) Lines: 32 Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail