commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch: FYI: gnu.java.io.PlatformHelper


From: Michael Koch
Subject: Re: Patch: FYI: gnu.java.io.PlatformHelper
Date: Sat, 24 Jan 2004 11:19:28 +0100
User-agent: Mutt/1.3.28i

On Wed, Jan 21, 2004 at 07:05:57AM -0700, Eric Blake wrote:
> Michael Koch wrote:
> >On Wed, Jan 21, 2004 at 11:20:24AM +0100, Jeroen Frijters wrote:
> >
> >
> >>+    int len = path.length();
> >>+    return len > 0 && beginWithRootPathPrefix(path) == len;
> >
> >
> >just a thought but wouldnt it be cleaner to write this:
> >
> >   return (path.length() > 0 && beginWithRootPathPrefix(path) == 
> >   path.length();
> >
> >Compilers are/should be smart enough to optimize it to write path.length
> >into a register and use it twice.
> 
> Actually, jikes does not do CSE when emitting bytecode; it assumes that any 
> common subexpression elimination will be done by a JIT.  Therefore, 
> Jeroen's style produces a smaller .class file than Michael's.  Besides, 
> path.length() is a function call, and it becomes very hard for the compiler 
> to guarantee that it will return the same value twice; manually caching the 
> result generally results in fewer method invocations.

Perhaps I think to gcj oriented. gcj inlines this at -O2 and this no
real method call is generated at all.


Michael




reply via email to

[Prev in Thread] Current Thread [Next in Thread]