You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/10/16 12:40:02 UTC
[GitHub] [dolphinscheduler] DarkAssassinator commented on a diff in pull request #12388: [Fix-12368] [Task Plugin] Fix DataX plugin NPE issue.
DarkAssassinator commented on code in PR #12388:
URL: https://github.com/apache/dolphinscheduler/pull/12388#discussion_r996437584
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java:
##########
@@ -393,18 +392,17 @@ private String buildShellCommandFile(String jobConfigFilePath, Map<String, Prope
}
// datax python command
- StringBuilder sbr = new StringBuilder();
Review Comment:
@EricGao888 @fuchanghai Sure, because JVM internally compiler will geneate axactly the same bytecode and `String +` and `StringBuilder.append` will have the same performance and the same memory usage, but String will be easier to read. We can get a readability benefit without any performace compromises. The replacement does not result in significant performance drawback on modern JVMs.
Please check the following screenshot, the modern JVM will pptimize `String +` to `StringBuilder.append`, so they are same.

If just compare `String` with `StringBuilder`, on most cases, using String is more practical and logical. It is not always better to concatenate string with plus sign (+). For example, StringBuilder's append method is more logical if you change your string in a loop because of its mutability.
For more details, please check [JLS: 15.18.1. String Concatenation Operator +](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.18.1)
And current IDEA is so smart, it will suggests you to change it for better code readability. It is equivalent to the optimization of the compiler, so IDEA detects that the two are equivalent. In order to make the code more concise, it will give some tips. thx
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org