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

Reviewed-by: liach, naoto, jlu
  • Loading branch information
lingjun-cg authored and D-D-H committed Jun 5, 2024
1 parent 67b9a08 commit d826127
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, 2023, 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 @@ -862,10 +862,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

3 comments on commit d826127

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@lingjun-cg
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d826127 Jun 7, 2024

Choose a reason for hiding this comment

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

@lingjun-cg To use the /backport command, you need to be in the OpenJDK census and your GitHub account needs to be linked with your OpenJDK username (how to associate your GitHub account with your OpenJDK username).

Please sign in to comment.