Re: Converting char(s) into String
- From: "Mike Schilling" <mscottschilling@xxxxxxxxxxx>
- Date: Mon, 12 Jun 2006 19:53:57 GMT
"Oliver Wong" <owong@xxxxxxxxxxxxxx> wrote in message
news:7xfjg.29561$771.11011@xxxxxxxxxxx
"Oliver Wong" <owong@xxxxxxxxxxxxxx> wrote in message
news:DCkig.27254$771.10711@xxxxxxxxxxx
[obviously, I meant String instead of StringBuffer here]Why would even a dumb compiler
produce worse code?
Perhaps because it depends on knowledge of the API. It might be
occasionally be desirable to run a Java program without any of Sun's API
available. If the compiler produced code using StringBuffer
, the JVM might report a "StringBuffer class not found", despite the fact
that the original source code never mentions StringBuffer.
I mentioned this mainly because in this competition I had entered for
writing an optimizing Java compiler, I had taken advantage of the fact
that I knew the behaviour of the StringBuffer class to replace certain
calls with others. If I recall correctly, it was something like changing
this:
<pseudo bytecode>
invoke 0 parameter constructor of StringBuffer.
dup
push "Foo"
invoke 1 parameter append method.
dup
push "Bar"
invoke 1 parameter append method.
invoke 0 parameter toString
</pseudo bytecode>
to this:
<pseudo bytecode>
push "Foo"
invoke 1 parameter constructor of StringBuffer.
dup
push "Bar"
invoke 1 parameter append method.
invoke 0 parameter toString
</pseudo bytecode>
and the judges said I shouldn't have relied on information on the
semantics/behaviour of the API,
Uh-huh. It's OK to use one constructor and the append method, but using a
different constructor is cheating. What had they been smoking?
but they let it slide for this competition anyway.
.
- References:
- Converting char(s) into String
- From: ponga
- Re: Converting char(s) into String
- From: Mike Schilling
- Re: Converting char(s) into String
- From: Dimitri Maziuk
- Re: Converting char(s) into String
- From: Jussi Piitulainen
- Re: Converting char(s) into String
- From: Oliver Wong
- Re: Converting char(s) into String
- From: Oliver Wong
- Converting char(s) into String
- Prev by Date: jboss will not work externally
- Next by Date: Re: Feeling like a dope
- Previous by thread: Re: Converting char(s) into String
- Next by thread: Re: Converting char(s) into String
- Index(es):
Relevant Pages
|