Skip to content

Commit

Permalink
Use String.replace instead of replaceAll when possible
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <fbricon@gmail.com>
  • Loading branch information
fbricon authored and datho7561 committed May 26, 2021
1 parent 8ca69a1 commit db84e94
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Expand Up @@ -108,10 +108,10 @@ public Snippet deserialize(JsonElement json, Type typeOfT, JsonDeserializationCo
String label = labelElt.getAsString();
if (label.contains("$")) {
if (!StringUtils.isEmpty(snippet.getDescription())) {
label = label.replaceAll("\\$description", snippet.getDescription());
label = label.replace("$description", snippet.getDescription());
}
if (!snippet.getPrefixes().isEmpty()) {
label = label.replaceAll("\\$prefix", snippet.getPrefixes().get(0));
label = label.replace("$prefix", snippet.getPrefixes().get(0));
}
}
snippet.setLabel(label);
Expand Down
Expand Up @@ -272,6 +272,6 @@ public static Path getPath(String uri) {
* @return the path with replaced spaces.
*/
public static String encodePath(String path) {
return path.replaceAll(" ", "%20");
return path.replace(" ", "%20");
}
}
Expand Up @@ -943,8 +943,8 @@ public static LocationLink ll(final String uri, final Range originRange, Range t
public static void assertLocationLink(List<? extends LocationLink> actual, LocationLink... expected) {
assertEquals(expected.length, actual.size());
for (int i = 0; i < expected.length; i++) {
actual.get(i).setTargetUri(actual.get(i).getTargetUri().replaceAll("file:///", "file:/"));
expected[i].setTargetUri(expected[i].getTargetUri().replaceAll("file:///", "file:/"));
actual.get(i).setTargetUri(actual.get(i).getTargetUri().replace("file:///", "file:/"));
expected[i].setTargetUri(expected[i].getTargetUri().replace("file:///", "file:/"));
}
assertArrayEquals(expected, actual.toArray());
}
Expand Down

0 comments on commit db84e94

Please sign in to comment.