8336278: Micro-optimize Replace String.format("%n") to System.lineSeparator

Reviewed-by: dnsimon, shade
This commit is contained in:
Shaojin Wen 2024-07-12 21:49:28 +00:00 committed by Chen Liang
parent 1f6e106b45
commit 4957145e6c
3 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -37,7 +37,7 @@ import jdk.vm.ci.meta.Signature;
*/
public class CodeUtil {
public static final String NEW_LINE = String.format("%n");
public static final String NEW_LINE = System.lineSeparator();
public static final int K = 1024;
public static final int M = 1024 * 1024;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -318,7 +318,7 @@ final class HotSpotMethodData implements MetaspaceObject {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
String nl = String.format("%n");
String nl = System.lineSeparator();
String nlIndent = String.format("%n%38s", "");
sb.append("Raw method data for ");
sb.append(method.format("%H.%n(%p)"));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -36,7 +36,7 @@ abstract class StructuredWriter {
private int column;
// print first event immediately so tool feels responsive
private boolean first = true;
private String lineSeparator = String.format("%n");
private String lineSeparator = System.lineSeparator();
StructuredWriter(PrintWriter p) {
out = p;