mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Using Regular expression objects for splitting and replacing in strings. (#1059)
* Where possible, replace .split() and .replace() methods with compiled Regex patterns. This prevents a regular expression from being compiled multiple times during runtime. * Forgot making one instance `private static final`.
This commit is contained in:
committed by
Rob Bygrave
parent
08263c4588
commit
36a5610e25
@@ -3,6 +3,8 @@ package io.ebeaninternal.server.query;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import io.ebeaninternal.server.el.ElPropertyDeploy;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -15,6 +17,8 @@ import java.util.TreeSet;
|
||||
*/
|
||||
class SqlTreeAlias {
|
||||
|
||||
private static final Pattern TABLE_ALIAS_REPLACE = Pattern.compile("${}", Pattern.LITERAL);
|
||||
|
||||
private int counter;
|
||||
|
||||
private int manyWhereCounter;
|
||||
@@ -178,9 +182,9 @@ class SqlTreeAlias {
|
||||
private String parseRootAlias(String clause) {
|
||||
|
||||
if (rootTableAlias == null) {
|
||||
return clause.replace("${}", "");
|
||||
return TABLE_ALIAS_REPLACE.matcher(clause).replaceAll("");
|
||||
} else {
|
||||
return clause.replace("${}", rootTableAlias + ".");
|
||||
return TABLE_ALIAS_REPLACE.matcher(clause).replaceAll(Matcher.quoteReplacement(rootTableAlias + "."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user