Skip to content

Commit

Permalink
8333462: Performance regression of new DecimalFormat() when compare t…
Browse files Browse the repository at this point in the history
…o jdk11

Backport-of: d826127970bd2ae8bf4cacc3c55634dc5af307c4
  • Loading branch information
lingjun-cg authored and DamonFool committed Jun 28, 2024
1 parent b15ec4a commit 7ff9ec6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/java.base/share/classes/java/text/DecimalFormatSymbols.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
Expand Down Expand Up @@ -849,10 +849,13 @@ private void initialize( Locale locale ) {
* Obtains non-format single character from String
*/
private char findNonFormatChar(String src, char defChar) {
return (char)src.chars()
.filter(c -> Character.getType(c) != Character.FORMAT)
.findFirst()
.orElse(defChar);
for (int i = 0; i < src.length(); i++) {
char c = src.charAt(i);
if (Character.getType(c) != Character.FORMAT) {
return c;
}
}
return defChar;
}

/**
Expand Down

1 comment on commit 7ff9ec6

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.