DATAJPA-1333 - Minor performance improvements.
Original pull request: #269.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.jpa.convert;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -91,7 +92,7 @@ public class QueryByExamplePredicateBuilder {
|
||||
return predicates.iterator().next();
|
||||
}
|
||||
|
||||
Predicate[] array = predicates.toArray(new Predicate[predicates.size()]);
|
||||
Predicate[] array = predicates.toArray(new Predicate[0]);
|
||||
|
||||
return matcher.isAllMatching() ? cb.and(array) : cb.or(array);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ public class JpaSort extends Sort {
|
||||
public static <A extends Attribute<T, S>, T, S> Path<T, S> path(A attribute) {
|
||||
|
||||
Assert.notNull(attribute, "Attribute must not be null!");
|
||||
return new Path<T, S>(Arrays.asList(attribute));
|
||||
return new Path<T, S>(Collections.singletonList(attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ public class JpaSort extends Sort {
|
||||
public static <P extends PluralAttribute<T, ?, S>, T, S> Path<T, S> path(P attribute) {
|
||||
|
||||
Assert.notNull(attribute, "Attribute must not be null!");
|
||||
return new Path<T, S>(Arrays.asList(attribute));
|
||||
return new Path<T, S>(Collections.singletonList(attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +240,7 @@ public class JpaSort extends Sort {
|
||||
|
||||
Assert.notEmpty(properties, "Properties must not be empty!");
|
||||
|
||||
List<Order> orders = new ArrayList<Order>();
|
||||
List<Order> orders = new ArrayList<Order>(properties.size());
|
||||
|
||||
for (String property : properties) {
|
||||
orders.add(new JpaOrder(direction, property));
|
||||
@@ -384,7 +384,7 @@ public class JpaSort extends Sort {
|
||||
Assert.notEmpty(properties, "Properties must not be empty!");
|
||||
Assert.noNullElements(properties, "Properties must not contain null values!");
|
||||
|
||||
List<Order> orders = new ArrayList<Order>();
|
||||
List<Order> orders = new ArrayList<Order>(properties.length);
|
||||
|
||||
for (String property : properties) {
|
||||
orders.add(new JpaOrder(getDirection(), property, getNullHandling(), isIgnoreCase(), this.unsafe));
|
||||
|
||||
@@ -148,7 +148,7 @@ public class Querydsl {
|
||||
private <T> JPQLQuery<T> addOrderByFrom(QSort qsort, JPQLQuery<T> query) {
|
||||
|
||||
List<OrderSpecifier<?>> orderSpecifiers = qsort.getOrderSpecifiers();
|
||||
return query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
|
||||
return query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -751,12 +751,12 @@ public class SimpleJpaRepository<T, ID extends Serializable>
|
||||
* @param query must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
private static Long executeCountQuery(TypedQuery<Long> query) {
|
||||
private static long executeCountQuery(TypedQuery<Long> query) {
|
||||
|
||||
Assert.notNull(query, "TypedQuery must not be null!");
|
||||
|
||||
List<Long> totals = query.getResultList();
|
||||
Long total = 0L;
|
||||
long total = 0L;
|
||||
|
||||
for (Long element : totals) {
|
||||
total += element == null ? 0 : element;
|
||||
|
||||
@@ -71,8 +71,8 @@ public class BeanDefinitionUtils {
|
||||
*/
|
||||
public static Iterable<String> getEntityManagerFactoryBeanNames(ListableBeanFactory beanFactory) {
|
||||
|
||||
Set<String> names = new HashSet<String>();
|
||||
names.addAll(asList(beanNamesForTypeIncludingAncestors(beanFactory, EntityManagerFactory.class, true, false)));
|
||||
String[] beanNames = beanNamesForTypeIncludingAncestors(beanFactory, EntityManagerFactory.class, true, false);
|
||||
Set<String> names = new HashSet<String>(asList(beanNames));
|
||||
|
||||
for (String factoryBeanName : beanNamesForTypeIncludingAncestors(beanFactory,
|
||||
AbstractEntityManagerFactoryBean.class, true, false)) {
|
||||
|
||||
Reference in New Issue
Block a user