8284775: Simplify String.substring(_, length()) calls

Reviewed-by: bpb, serb
This commit is contained in:
Andrey Turbanov 2022-04-13 19:08:44 +00:00
parent 249d54f93d
commit bf1c3ef02b
6 changed files with 14 additions and 19 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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
@ -151,7 +151,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
String nm = getClass().getName();
int index = nm.lastIndexOf('.');
if (index >= 0) {
nm = nm.substring(index+1, nm.length());
nm = nm.substring(index+1);
}
return nm;
}
@ -249,7 +249,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
/* In an ideal situation, the following check would not be necessary
* and we would replace the color any time the previous color was a
* UIResouce. However, it turns out that there is existing code that
* UIResource. However, it turns out that there is existing code that
* uses the following inadvisable pattern to turn a text area into
* what appears to be a multi-line label:
*

View File

@ -847,7 +847,7 @@ public abstract class FontConfiguration {
start = end + 1;
}
if (sequence.length() > start) {
parts.add(sequence.substring(start, sequence.length()));
parts.add(sequence.substring(start));
}
return parts;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, 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
@ -427,7 +427,7 @@ class MotifColorUtilities {
for (int i=0;i<8;i++) {
temp = bfr.readLine();
color = temp.substring(1,temp.length());
color = temp.substring(1);
r = Integer.parseInt(color.substring(0, 4), 16) >> 8;
g = Integer.parseInt(color.substring(4, 8), 16) >> 8;
b = Integer.parseInt(color.substring(8, 12), 16) >> 8;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, 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
@ -202,7 +202,7 @@ class XFileDialogPeer extends XDialogPeer
// Fixed 6260650: FileDialog.getDirectory() does not return null when file dialog is cancelled
// After showing we should display 'user.dir' as current directory
// if user didn't set directory programatically
// if user didn't set directory programmatically
pathField = new TextField(savedDir != null ? savedDir : userDir);
@SuppressWarnings("serial") // Anonymous class
Choice tmp = new Choice() {
@ -728,7 +728,7 @@ class XFileDialogPeer extends XDialogPeer
int i;
if ((i=dir.indexOf("~")) != -1) {
dir = dir.substring(0,i) + System.getProperty("user.home") + dir.substring(i+1,dir.length());
dir = dir.substring(0,i) + System.getProperty("user.home") + dir.substring(i+1);
}
File fe = new File(dir).getAbsoluteFile();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, 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
@ -1567,7 +1567,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
@Override
protected Object lazilyLoadDesktopProperty(String name) {
if (name.startsWith(prefix)) {
String cursorName = name.substring(prefix.length(), name.length()) + postfix;
String cursorName = name.substring(prefix.length()) + postfix;
try {
return Cursor.getSystemCustomCursor(cursorName);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2022, 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
@ -39,8 +39,6 @@ import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FileDialog;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
@ -137,9 +135,6 @@ import sun.awt.Win32GraphicsEnvironment;
import sun.awt.datatransfer.DataTransferer;
import sun.awt.util.PerformanceLogger;
import sun.awt.util.ThreadGroupUtils;
import sun.font.FontManager;
import sun.font.FontManagerFactory;
import sun.font.SunFontManager;
import sun.java2d.d3d.D3DRenderQueue;
import sun.java2d.opengl.OGLRenderQueue;
import sun.print.PrintJob2D;
@ -216,7 +211,7 @@ public final class WToolkit extends SunToolkit implements Runnable {
* will lead to undefined behavior.
*
* embeddedInit must be called before the WToolkit() constructor.
* embeddedDispose should be called before the applicaton terminates the
* embeddedDispose should be called before the application terminates the
* Java VM. It is currently unsafe to reinitialize the toolkit again
* after it has been disposed. Instead, awt.dll must be reloaded and the
* class loader which loaded WToolkit must be finalized before it is
@ -937,7 +932,7 @@ public final class WToolkit extends SunToolkit implements Runnable {
@Override
protected Object lazilyLoadDesktopProperty(String name) {
if (name.startsWith(prefix)) {
String cursorName = name.substring(prefix.length(), name.length()) + postfix;
String cursorName = name.substring(prefix.length()) + postfix;
try {
return Cursor.getSystemCustomCursor(cursorName);