HHH-14137 Some more string check performnance optimisations

This commit is contained in:
Sanne Grinovero 2020-08-06 17:46:01 +02:00
parent ea333d23b6
commit 6392de46d0
8 changed files with 15 additions and 9 deletions

View File

@ -11,6 +11,7 @@ import org.hibernate.boot.jaxb.Origin;
import org.hibernate.boot.jaxb.cfg.spi.JaxbCfgHibernateConfiguration;
import org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationException;
import org.hibernate.internal.util.xml.XsdException;
import org.jboss.logging.Logger;
@ -136,7 +137,7 @@ public class JaxbCfgProcessor {
}
private boolean isNamespaced(StartElement startElement) {
return ! "".equals( startElement.getName().getNamespaceURI() );
return StringHelper.isNotEmpty( startElement.getName().getNamespaceURI() );
}
private Schema schema;

View File

@ -26,6 +26,7 @@ import org.hibernate.boot.jaxb.spi.Binder;
import org.hibernate.boot.jaxb.spi.Binding;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.internal.util.StringHelper;
import org.jboss.logging.Logger;
/**
@ -151,7 +152,7 @@ public abstract class AbstractBinder implements Binder {
protected abstract Binding doBind(XMLEventReader staxEventReader, StartElement rootElementStartEvent, Origin origin);
protected static boolean hasNamespace(StartElement startElement) {
return ! "".equals( startElement.getName().getNamespaceURI() );
return StringHelper.isNotEmpty( startElement.getName().getNamespaceURI() );
}
@SuppressWarnings("unchecked")

View File

@ -21,6 +21,7 @@ import javax.xml.stream.events.XMLEvent;
import javax.xml.stream.util.EventReaderDelegate;
import org.hibernate.boot.xsd.MappingXsdSupport;
import org.hibernate.internal.util.StringHelper;
/**
* A StAX EventReader for {@code hbm.xml} files to add namespaces in documents
@ -67,7 +68,7 @@ public class HbmEventReader extends EventReaderDelegate {
private StartElement applyNamespace(StartElement startElement) {
final List<Namespace> targetNamespaces = new ArrayList<Namespace>();
if ( "".equals( startElement.getName().getNamespaceURI() ) ) {
if ( StringHelper.isEmpty( startElement.getName().getNamespaceURI() ) ) {
// add the default namespace mapping
targetNamespaces.add( xmlEventFactory.createNamespace( MappingXsdSupport.INSTANCE.hbmXsd().getNamespaceUri() ) );
}

View File

@ -7,6 +7,7 @@
package org.hibernate.boot.model.naming;
import org.hibernate.boot.model.source.spi.AttributePath;
import org.hibernate.internal.util.StringHelper;
/**
* An ImplicitNamingStrategy implementation which uses full composite paths
@ -31,7 +32,7 @@ public class ImplicitNamingStrategyComponentPathImpl extends ImplicitNamingStrat
public static void process(AttributePath attributePath, StringBuilder sb) {
if ( attributePath.getParent() != null ) {
process( attributePath.getParent(), sb );
if ( !"".equals( attributePath.getParent().getProperty() ) ) {
if ( StringHelper.isNotEmpty( attributePath.getParent().getProperty() ) ) {
sb.append( '_' );
}
}

View File

@ -49,7 +49,7 @@ public class NamedQueryBinder {
for ( Object content : namedQueryBinding.getContent() ) {
if ( String.class.isInstance( content ) ) {
String trimmed = ((String)content).trim();
if (!"".equals(trimmed)) {
if ( StringHelper.isNotEmpty( trimmed ) ) {
query = trimmed;
}
}

View File

@ -72,7 +72,7 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information
""
)
);
if ( !"".equals( extraPhysycalTableTypesConfig.trim() ) ) {
if ( ! StringHelper.isEmptyOrWhiteSpace( extraPhysycalTableTypesConfig ) ) {
this.extraPhysicalTableTypes = StringHelper.splitTrimmingTokens(
",;",
extraPhysycalTableTypesConfig,

View File

@ -43,6 +43,7 @@ import org.hibernate.envers.internal.EnversMessageLogger;
import org.hibernate.envers.internal.tools.MappingTools;
import org.hibernate.envers.internal.tools.ReflectionTools;
import org.hibernate.envers.internal.tools.StringTools;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.loader.PropertyPath;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Property;
@ -617,7 +618,7 @@ public class AuditedPropertiesReader {
private void setPropertyRelationMappedBy(XProperty property, PropertyAuditingData propertyData) {
final OneToMany oneToMany = property.getAnnotation( OneToMany.class );
if ( oneToMany != null && !"".equals( oneToMany.mappedBy() ) ) {
if ( oneToMany != null && StringHelper.isNotEmpty( oneToMany.mappedBy() ) ) {
propertyData.setRelationMappedBy( oneToMany.mappedBy() );
}
}
@ -626,7 +627,7 @@ public class AuditedPropertiesReader {
final AuditMappedBy auditMappedBy = property.getAnnotation( AuditMappedBy.class );
if ( auditMappedBy != null ) {
propertyData.setAuditMappedBy( auditMappedBy.mappedBy() );
if ( !"".equals( auditMappedBy.positionMappedBy() ) ) {
if ( StringHelper.isNotEmpty( auditMappedBy.positionMappedBy() ) ) {
propertyData.setPositionMappedBy( auditMappedBy.positionMappedBy() );
}
}

View File

@ -12,6 +12,7 @@ import org.hibernate.envers.Audited;
import org.hibernate.envers.ModificationStore;
import org.hibernate.envers.configuration.internal.GlobalConfiguration;
import org.hibernate.envers.configuration.internal.metadata.MetadataTools;
import org.hibernate.internal.util.StringHelper;
/**
* Reads the audited properties for components.
@ -45,7 +46,7 @@ public class ComponentAuditedPropertiesReader extends AuditedPropertiesReader {
propertyData.setRelationTargetAuditMode( aud.targetAuditMode() );
propertyData.setUsingModifiedFlag( checkUsingModifiedFlag( aud ) );
propertyData.setModifiedFlagName( MetadataTools.getModifiedFlagPropertyName( propertyName, modifiedFlagSuffix ) );
if( aud.modifiedColumnName() != null && !"".equals( aud.modifiedColumnName() ) ) {
if ( StringHelper.isNotEmpty( aud.modifiedColumnName() ) ) {
propertyData.setExplicitModifiedFlagName( aud.modifiedColumnName() );
}
}