Merge pull request #71 from eolivelli/fix/OPENJPA-2820-delim

OPENJPA-2820 Track when a DBIdentifier is already delimited in order to save memory allocations and cpu
This commit is contained in:
Romain Manni-Bucau 2020-09-30 12:24:21 +02:00 committed by GitHub
commit 049c2ef163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -142,6 +142,7 @@ public class DBIdentifier extends IdentifierImpl implements Cloneable, Identifie
if (DBIdentifierType.CONSTANT != getType() && DBIdentifierType.COLUMN_DEFINITION != getType()) { if (DBIdentifierType.CONSTANT != getType() && DBIdentifierType.COLUMN_DEFINITION != getType()) {
if (delimit) { if (delimit) {
name = Normalizer.delimit(name, true); name = Normalizer.delimit(name, true);
setNameDelimited(true);
} else { } else {
name = Normalizer.normalizeString(name); name = Normalizer.normalizeString(name);
} }
@ -325,6 +326,7 @@ public class DBIdentifier extends IdentifierImpl implements Cloneable, Identifie
sName.setNameInternal(getNameInternal()); sName.setNameInternal(getNameInternal());
sName.setType(getType()); sName.setType(getType());
sName.setIgnoreCase(getIgnoreCase()); sName.setIgnoreCase(getIgnoreCase());
sName.setNameDelimited(isNameDelimited());
return sName; return sName;
} }
@ -859,7 +861,7 @@ public class DBIdentifier extends IdentifierImpl implements Cloneable, Identifie
* @param name * @param name
*/ */
public static DBIdentifier removeDelimiters(DBIdentifier name) { public static DBIdentifier removeDelimiters(DBIdentifier name) {
if (DBIdentifier.isNull(name)) { if (DBIdentifier.isNull(name) || !name.isDelimited()) {
return name; return name;
} }
if (!name.isDelimited()) { if (!name.isDelimited()) {
@ -927,7 +929,7 @@ public class DBIdentifier extends IdentifierImpl implements Cloneable, Identifie
if (DBIdentifier.isEmpty(this)) { if (DBIdentifier.isEmpty(this)) {
return false; return false;
} }
return Normalizer.isDelimited(getNameInternal()); return isNameDelimited() || Normalizer.isDelimited(getNameInternal());
} }
/** /**

View File

@ -28,6 +28,7 @@ public class IdentifierImpl implements Identifier, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String _name = null; private String _name = null;
private boolean nameDelimited = false;
protected IdentifierImpl() {} protected IdentifierImpl() {}
@ -45,6 +46,14 @@ public class IdentifierImpl implements Identifier, Serializable {
return _name; return _name;
} }
public boolean isNameDelimited() {
return nameDelimited;
}
public void setNameDelimited(boolean nameDelimited) {
this.nameDelimited = nameDelimited;
}
@Override @Override
public String toString() { public String toString() {
return getName(); return getName();