Skip to content

Commit

Permalink
[41] Do not delegate to EMF on failed id lookup
Browse files Browse the repository at this point in the history
EMF's default implementation is slow, and we can trust our own local
idToEObjectMap.

Bug: #41
Signed-off-by: Pierre-Charles David <[email protected]>
  • Loading branch information
pcdavid authored and sbegaudeau committed Jun 16, 2024
1 parent a0b726c commit 1f44029
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 Obeo.
* Copyright (c) 2020, 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -57,7 +57,7 @@ public class JsonResourceImpl extends ResourceImpl implements JsonResource {
/**
* The options.
*/
private Map<Object, Object> resourceOptions = new HashMap<Object, Object>();
private Map<Object, Object> resourceOptions = new HashMap<>();

/**
* Use to know is an id is used to identified an EObject.
Expand Down Expand Up @@ -111,7 +111,7 @@ public static String toJson(EObject eObject, Map<Object, Object> options) {
* @return the json representation of the given Resource
*/
public static String toJson(Resource resource, Map<Object, Object> options) {
Map<Object, Object> loadOptions = new HashMap<Object, Object>();
Map<Object, Object> loadOptions = new HashMap<>();
if (options != null) {
loadOptions.putAll(options);
}
Expand Down Expand Up @@ -444,12 +444,8 @@ public void setID(EObject eObject, String id) {
@Override
protected EObject getEObjectByID(String id) {
if (this.useID) {
EObject eObject = this.idToEObjectMap.get(id);
if (eObject != null) {
return eObject;
}
return this.idToEObjectMap.get(id);
}

return super.getEObjectByID(id);
}

Expand Down

0 comments on commit 1f44029

Please sign in to comment.