How to accelerate this program?

Li Jie cpunion at gmail.com
Mon Apr 3 19:33:08 PDT 2006


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.





More information about the Digitalmars-d mailing list