Skip to content

Commit

Permalink
removes copying of EObjects to Export
Browse files Browse the repository at this point in the history
EMF is not Threadsafe and will always be handled that way. Making a copy
is honourable, but will result in this case in a larger memory
footprint, that can be avoided.

Signed-off-by: Juergen Albert <j.albert@data-in-motion.biz>
  • Loading branch information
juergen-albert committed Aug 31, 2023
1 parent cb20aea commit fb90b96
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion org.gecko.emf.exporter.ods/bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Bundle-Version: 1.0.1.SNAPSHOT
Bundle-Version: 1.0.2.SNAPSHOT
Bundle-Name: Gecko EMF ODS Exporter
Bundle-Description: ODS (OpenDocument Spreadsheet) Exporter for EMF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
*/
package org.gecko.emf.exporter.ods;

import static java.util.stream.Collectors.toList;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -161,10 +159,8 @@ public void exportEObjectsTo(List<EObject> eObjects, OutputStream outputStream,
// lack id field
final Map<String, String> eObjectsPseudoIDs = new HashMap<String, String>();

final List<EObject> eObjectsSafeCopy = safeCopy(eObjects);

// pseudo IDs are needed before main processing starts
generatePseudoIDs(eObjectsSafeCopy, eObjectsPseudoIDs);
generatePseudoIDs(eObjects, eObjectsPseudoIDs);

// @formatter:off
createSheets(document,
Expand All @@ -173,7 +169,7 @@ public void exportEObjectsTo(List<EObject> eObjects, OutputStream outputStream,
eObjectsEnums,
eObjectsPseudoIDs,
eObjectsSheets,
eObjectsSafeCopy,
eObjects,
exportOptions);
// @formatter:on

Expand All @@ -184,7 +180,7 @@ public void exportEObjectsTo(List<EObject> eObjects, OutputStream outputStream,
eObjectsEnums,
eObjectsPseudoIDs,
eObjectsSheets,
eObjectsSafeCopy,
eObjects,
exportOptions);
// @formatter:on

Expand Down Expand Up @@ -1336,8 +1332,4 @@ private String constructMetadataSheetName(String metadataSheetName) {
private boolean isProcessed(Set<String> eObjectsIdentifiers, EObject eObject) {
return eObjectsIdentifiers.contains(getEObjectIdentifier(eObject));
}

private List<EObject> safeCopy(List<EObject> eObjects) {
return EcoreUtil.copyAll(eObjects).stream().collect(toList());
}
}

0 comments on commit fb90b96

Please sign in to comment.