Skip to content

Commit

Permalink
use computeIfAbsent and Arrays.asList instead of creating a new Array
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenporras committed Nov 26, 2024
1 parent db67361 commit 972444e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,13 @@ public abstract class AbstractScopeNameProvider implements IScopeNameProvider {
*/
@Override
public Iterable<INameFunction> getNameFunctions(final EClass type) {
Iterable<INameFunction> result = nameFunctionCache.get(type);
if (result == null) {
result = internalGetNameFunctions(type);
return nameFunctionCache.computeIfAbsent(type, eClass -> {
Iterable<INameFunction> result = internalGetNameFunctions(eClass);
if (result == null) {
result = getDefaultNames(type);
result = getDefaultNames(eClass);
}
nameFunctionCache.put(type, result);
}
return result;
return result;
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
package com.avaloq.tools.ddk.xtext.scoping;

import java.text.MessageFormat;
import java.util.Arrays;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.xtext.naming.QualifiedName;
Expand Down Expand Up @@ -109,7 +110,7 @@ public QualifiedName apply(final EObject from) {
* @return The name functions
*/
public static Iterable<INameFunction> fromFeatures(final EStructuralFeature... nameFeatures) {
return Iterables.transform(Lists.newArrayList(nameFeatures), new Function<EStructuralFeature, INameFunction>() {
return Iterables.transform(Arrays.asList(nameFeatures), new Function<EStructuralFeature, INameFunction>() {
@Override
public INameFunction apply(final EStructuralFeature from) {
return fromFeature(from);
Expand Down

0 comments on commit 972444e

Please sign in to comment.