How to accelerate this program?
Dave
Dave_member at pathlink.com
Mon Apr 3 21:42:40 PDT 2006
In article <e0slt4$2cki$1 at digitaldaemon.com>, Li Jie says...
>
>In article <e0rcej$10it$1 at digitaldaemon.com>, Wang Zhen says...
>
>>Two improvements based on your first D version:
>>0. Output in a separate loop.
>>1. Remove the "if(!(email in emails))" check.
>>
>>Code:
>>
>>while(!feof(fin)){
>> fgets(cast(char*)buffer, READ_SIZE, fin);
>> emails[toString(buffer)] = 0;
>>}
>>foreach(char[] k, int v; emails)
>> fputs(cast(char*)k, fout);
>
>Thanks.
>
>It takes 1080 ms on my system, it's not fast enough.
>I think "cast(char*)(char[])" and "toString" called too much, and it's very
>slowly.
>
That won't give the correct output because the buffer is overwritten with each
fgets and a memcpy is *not* done somewhere in the background for the AA keys.
More information about the Digitalmars-d
mailing list