From d6bb3f8c8011d9e485f0ab9e2283ce148864f0fe Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Wed, 21 Nov 2018 12:53:16 +0100 Subject: [PATCH] Make code in UnnecessaryUnicodeEscapeInspection shorter The keyword "while" at the beginning of a line usually starts a while loop instead of ending a do-while loop. To avoid further confusion, replace the do-while loop with a typical while-loop. --- .../UnnecessaryUnicodeEscapeInspection.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/internationalization/UnnecessaryUnicodeEscapeInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/internationalization/UnnecessaryUnicodeEscapeInspection.java index 0a4f6edec767..396e4a61f423 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/internationalization/UnnecessaryUnicodeEscapeInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/internationalization/UnnecessaryUnicodeEscapeInspection.java @@ -131,14 +131,10 @@ public class UnnecessaryUnicodeEscapeInspection extends BaseInspection { if (!isEscape) { continue; } - int nextChar = i; - do { - nextChar++; - if (nextChar >= length) { - break; - } + int nextChar = i + 1; + while (nextChar < length && text.charAt(nextChar) == 'u') { + nextChar++; // \\uuuu0061 is a legal Unicode escape } - while (text.charAt(nextChar) == 'u'); // \\uuuu0061 is a legal unicode escape if (nextChar == i + 1 || nextChar + 3 >= length) { continue; }