From 4957145e6c823bfaa638a77457da5c031af978b9 Mon Sep 17 00:00:00 2001 From: Shaojin Wen Date: Fri, 12 Jul 2024 21:49:28 +0000 Subject: [PATCH] 8336278: Micro-optimize Replace String.format("%n") to System.lineSeparator Reviewed-by: dnsimon, shade --- .../share/classes/jdk/vm/ci/code/CodeUtil.java | 4 ++-- .../share/classes/jdk/vm/ci/hotspot/HotSpotMethodData.java | 4 ++-- .../share/classes/jdk/jfr/internal/tool/StructuredWriter.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeUtil.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeUtil.java index d04823d3e4c..59af250a695 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeUtil.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeUtil.java @@ -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; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodData.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodData.java index 1096771919c..bc76b7656fa 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodData.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodData.java @@ -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)")); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/StructuredWriter.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/StructuredWriter.java index 3892e850218..8e16e5fb0bf 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/StructuredWriter.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/StructuredWriter.java @@ -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;