# HG changeset patch # User rgoel # Date 1525428864 -19800 # Node ID 41069c4fad29ee96c73a931c0f18a6ef4f5ac6f4 # Parent 9042ffe5b7fe060f3e1de49bade293d9a7d29e44 8202582: DateTimeFormatterBuilder.parseOffsetBased unnecessarily calls toString() Summary: call text.subSequence() before calling toString() on input string Reviewed-by: igerasim diff -r 9042ffe5b7fe -r 41069c4fad29 src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java --- a/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Fri May 04 11:41:35 2018 +0200 +++ b/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Fri May 04 15:44:24 2018 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, 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 @@ -4262,7 +4262,7 @@ * @return the position after the parse */ private int parseOffsetBased(DateTimeParseContext context, CharSequence text, int prefixPos, int position, OffsetIdPrinterParser parser) { - String prefix = text.toString().substring(prefixPos, position).toUpperCase(); + String prefix = text.subSequence(prefixPos, position).toString().toUpperCase(); if (position >= text.length()) { context.setParsed(ZoneId.of(prefix)); return position;