由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - StringBuffer
相关主题
问个java String问题Do the two statements cost the same amount of time?
Refactoring long class step by step (1)一个简单得java程序,
请教关于float的精度和比较求助大家 如何用 Eclipse 给一个project加入image (转载)
C++ IDE under Linuxanybody using Emacs for java debugging?
你身边有这样的人吗?--- code stylisttail call strange behavior on cl.exe
写Java程序不用IDE,那心灵得多强大啊qeustion about separation of interface and implementation in java
FP的教材是怎么误导人的C++ optimization question
对PyCharm屈服了……用C++的写的numerical or optimization solver library
相关话题的讨论汇总
话题: cases话题: append话题: think
进入Programming版参与讨论
1 (共1页)
c******n
发帖数: 4965
1
I see that today a lot of people still pay extra care to change StringA +
StringB into
StringBuffer.append(). but from what I observed from de-compiled bytecode,
A + B does generate StringBuffer.append(),
so I think it's bad in most cases to manually write out StringBuffer.append(
) since javac optimizes it to append() automatically anyway, while writing "
+" for human code reading is much cleaner and nicer to the eye
what do u think?
k**********g
发帖数: 989
2
Programmers are by their nature circumspect; because they cannot assume that
everything will work out fine. They must be prepared for the impossible,
because the impossible happens regularly in enterprise system logs.
It is the lack of automatic refactoring and profiling tool that causes
programmers to perpetuate the habit of bypassing compilers.
l*********s
发帖数: 5409
3
it is unnecessary in many cases, but you need to know the cases when
compiler will do the optimization and when it could not. It is mentally easy
to just stick to the same rule and don't worry about exceptions.
p*****2
发帖数: 21240
4
这个还真不知道。原来都优化了呀。
s*****n
发帖数: 5488
5
string is immuatable.
if you use + + + +
then you use several stringbuffers and have to gc them in future.
even you just one +, still you save a temp stringbuffer obj.
that maybe a huge performance difference for a large loop.

+
append(
"

【在 c******n 的大作中提到】
: I see that today a lot of people still pay extra care to change StringA +
: StringB into
: StringBuffer.append(). but from what I observed from de-compiled bytecode,
: A + B does generate StringBuffer.append(),
: so I think it's bad in most cases to manually write out StringBuffer.append(
: ) since javac optimizes it to append() automatically anyway, while writing "
: +" for human code reading is much cleaner and nicer to the eye
: what do u think?

1 (共1页)
进入Programming版参与讨论
相关主题
用C++的写的numerical or optimization solver library你身边有这样的人吗?--- code stylist
问个弱问题,C++为什么把interface和implementation分开?写Java程序不用IDE,那心灵得多强大啊
想写个简单的 JVM- 用C++还是JavaFP的教材是怎么误导人的
C语言能干嘛?对PyCharm屈服了……
问个java String问题Do the two statements cost the same amount of time?
Refactoring long class step by step (1)一个简单得java程序,
请教关于float的精度和比较求助大家 如何用 Eclipse 给一个project加入image (转载)
C++ IDE under Linuxanybody using Emacs for java debugging?
相关话题的讨论汇总
话题: cases话题: append话题: think