Skip to content

Commit

Permalink
Do not use a live view of the ExtensionFactoryMap (dsldevkit#857)
Browse files Browse the repository at this point in the history
* Do not use a live view of the ExtensionFactoryMap

as this means that each time the extensions are accesed, the transform method will be applied. This has a high cost when the extension map is used for all the sources in the workspace. Since the registered extensions do not change once the system is setup, it is much more efficient to map the keys only once.

* Update com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/ResourceServiceProviderUtil.java

Co-authored-by: João Dinis Ferreira <[email protected]>

---------

Co-authored-by: João Dinis Ferreira <[email protected]>
  • Loading branch information
rubenporras and joaodinissf authored Nov 28, 2023
1 parent 03baa61 commit 486b92d
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@
package com.avaloq.tools.ddk.xtext.resource;

import java.util.Collection;
import java.util.Set;
import java.util.stream.Collectors;

import org.eclipse.emf.common.util.URI;
import org.eclipse.xtext.resource.IResourceServiceProvider;

import com.google.common.base.Function;
import com.google.common.collect.Collections2;


/**
* Utility for {@link IResourceServiceProvider}.
Expand All @@ -31,14 +28,7 @@ public final class ResourceServiceProviderUtil {
* @return the registered resource extensions, never {@code null}
*/
public static Collection<String> getExtensions() {
final Set<String> extensions = IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().keySet();
Collection<String> decodedExtensions = Collections2.transform(extensions, new Function<String, String>() {
@Override
public String apply(final String from) {
return URI.decode(from);
}
});
return decodedExtensions;
return IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().keySet().stream().map(URI::decode).collect(Collectors.toSet());
}

/**
Expand Down

0 comments on commit 486b92d

Please sign in to comment.