Skip to content

Commit 4957145

Browse files
wenshaoliach
authored andcommitted
8336278: Micro-optimize Replace String.format("%n") to System.lineSeparator
Reviewed-by: dnsimon, shade
1 parent 1f6e106 commit 4957145

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
3737
*/
3838
public class CodeUtil {
3939

40-
public static final String NEW_LINE = String.format("%n");
40+
public static final String NEW_LINE = System.lineSeparator();
4141

4242
public static final int K = 1024;
4343
public static final int M = 1024 * 1024;

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -318,7 +318,7 @@ public boolean isProfileMature() {
318318
@Override
319319
public String toString() {
320320
StringBuilder sb = new StringBuilder();
321-
String nl = String.format("%n");
321+
String nl = System.lineSeparator();
322322
String nlIndent = String.format("%n%38s", "");
323323
sb.append("Raw method data for ");
324324
sb.append(method.format("%H.%n(%p)"));

src/jdk.jfr/share/classes/jdk/jfr/internal/tool/StructuredWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@ abstract class StructuredWriter {
3636
private int column;
3737
// print first event immediately so tool feels responsive
3838
private boolean first = true;
39-
private String lineSeparator = String.format("%n");
39+
private String lineSeparator = System.lineSeparator();
4040

4141
StructuredWriter(PrintWriter p) {
4242
out = p;

0 commit comments

Comments
 (0)