Skip to content

Commit

Permalink
#1780 avoid duplicate calls to toLowerCase()
Browse files Browse the repository at this point in the history
  • Loading branch information
asolntsev committed Aug 3, 2022
1 parent 66bb1b6 commit 231e7a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

import static java.util.Locale.ROOT;
import static org.apache.commons.lang3.StringUtils.isEmpty;

@ParametersAreNonnullByDefault
Expand All @@ -24,7 +23,7 @@ public PartialText(String text) {

@Override
protected boolean match(String actualText, String expectedText) {
return Html.text.contains(actualText, expectedText.toLowerCase(ROOT));
return Html.text.contains(actualText, expectedText);
}

@Nullable
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/codeborne/selenide/conditions/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

import static java.util.Locale.ROOT;
import static org.apache.commons.lang3.StringUtils.isEmpty;

@ParametersAreNonnullByDefault
Expand All @@ -33,8 +32,8 @@ protected boolean match(String actualText, String expectedText) {
@Override
protected boolean match(TextCheck textCheck, String actualText, String expectedText) {
return switch (textCheck) {
case FULL_TEXT -> Html.text.equals(actualText, expectedText.toLowerCase(ROOT));
case PARTIAL_TEXT -> Html.text.contains(actualText, expectedText.toLowerCase(ROOT));
case FULL_TEXT -> Html.text.equals(actualText, expectedText);
case PARTIAL_TEXT -> Html.text.contains(actualText, expectedText);
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/codeborne/selenide/impl/Html.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.codeborne.selenide.impl;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Locale;
import java.util.regex.Pattern;

import static java.util.Locale.ROOT;
import static java.util.regex.Pattern.DOTALL;

@ParametersAreNonnullByDefault
Expand All @@ -20,7 +20,7 @@ public boolean matchesSubstring(String text, String regex) {
}

public boolean contains(String text, String subtext) {
return reduceSpaces(text.toLowerCase(Locale.ROOT)).contains(reduceSpaces(subtext.toLowerCase(Locale.ROOT)));
return reduceSpaces(text.toLowerCase(ROOT)).contains(reduceSpaces(subtext.toLowerCase(ROOT)));
}

public boolean containsCaseSensitive(String text, String subtext) {
Expand Down

0 comments on commit 231e7a0

Please sign in to comment.