Final makes no difference?
BCS
BCS at pathlink.com
Thu Aug 24 09:16:29 PDT 2006
John Demme wrote:
> BCS wrote:
>
>
>>John Demme wrote:
>>
>>>I'm working on fixing and optimizing my XML parser. It uses some
>>>classes, and lots of virtual method calls, so I figured I could really
>>>increase my
>>>speed by making everything final. I made the classes final, and I put
>>>all of the methods in a big final{} block, but it made no appreciable
>>>difference in my time trials.
>>>
>>>Am I doing something wrong? Does DMD currently not optimize for final?
>>>Or are virtual method calls not nearly as bad as I thought? I'm making a
>>>ton of calls into small functions, so I was also hoping final methods
>>>would be candidates for inlining...
>>>
>>>I'm using DMD 0.163 and compiling with -O and -inline.
>>>
>>>Thanks
>>
>>if you aren't using inheritance, try using structs.
>
>
> Yeah, I know... I'm probably going to switch several of the classes over to
> structs, but the big main class implements an interface. I don't
> absolultely need the speed right now- I'm just wondering if any changes
> will be made in the future, and if I'm expecting the right thing from
> final.
>
That brings up another bone of mine. why can't struct implement an
interface? For that matter why not a function?
interface Foo
{
char fig(int);
int bar(char);
}
void fun()
{
char[] cmap;
int[] imap;
char first(int i){return cmap[i];}
int second(char c){return imap[c];}
Foo f = interface : Foo // making up a syntax...
{
alias first fig;
alias second bar;
}
FnTakingFoo(f);
}
More information about the Digitalmars-d-bugs
mailing list