소스 검색

avoid string concats

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884581 13f79535-47bb-0310-9956-ffa450edef68
tags/before_junit5_update
PJ Fanning 3 년 전
부모
커밋
1e43266c7a
1개의 변경된 파일17개의 추가작업 그리고 8개의 파일을 삭제
  1. 17
    8
      src/java/org/apache/poi/util/POILogger.java

+ 17
- 8
src/java/org/apache/poi/util/POILogger.java 파일 보기

@@ -96,17 +96,26 @@ public interface POILogger {
*/
default void log(int level, Object... objs) {
if (!check(level)) return;
StringBuilder sb = new StringBuilder(32);
Throwable lastEx = null;
for (int i=0; i<objs.length; i++) {
if (i == objs.length-1 && objs[i] instanceof Throwable) {
lastEx = (Throwable)objs[i];
} else {
sb.append(objs[i]);
String msg;
if (objs.length == 0) {
msg = "";
} else if (objs.length == 1) {
if (objs[0] instanceof Throwable) {
lastEx = (Throwable)objs[0];
}
msg = objs[0].toString();
} else {
StringBuilder sb = new StringBuilder(32);
for (int i=0; i<objs.length; i++) {
if (i == objs.length-1 && objs[i] instanceof Throwable) {
lastEx = (Throwable)objs[i];
} else {
sb.append(objs[i]);
}
}
msg = sb.toString();
}

String msg = sb.toString();
// log forging escape
msg = msg.replaceAll("[\r\n]+", " ");


Loading…
취소
저장