From 8971b90c863c4e6a91a15152e2916bfff09d6921 Mon Sep 17 00:00:00 2001 From: Sven Efftinge Date: Tue, 10 Feb 2015 16:24:54 +0100 Subject: [PATCH] [performance] some more small performance improvements. - avoid iterating adapters twice - avoid iterating whole tree - wrap DeflaterOutputStream with BufferedOutputStream - [typeresolver] check rootedExpressions first Change-Id: I14a02ec15a3bc22f4292c1361579cecc33b566f1 --- .../persistence/ResourceStorageWritable.xtend | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/persistence/ResourceStorageWritable.xtend b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/persistence/ResourceStorageWritable.xtend index 4b6b9ad27..47fec2e6f 100644 --- a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/persistence/ResourceStorageWritable.xtend +++ b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/persistence/ResourceStorageWritable.xtend @@ -20,6 +20,8 @@ import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor import org.eclipse.xtext.nodemodel.impl.SerializableNodeModel import org.eclipse.xtext.nodemodel.serialization.SerializationConversionContext +import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectOutputStream +import java.io.BufferedOutputStream /** * @author Sven Efftinge - Initial contribution and API @@ -54,25 +56,29 @@ import org.eclipse.xtext.nodemodel.serialization.SerializationConversionContext * Overriding methods should first delegate to super before adding their own entries. */ protected def void writeEntries(StorageAwareResource resource, ZipOutputStream zipOut) { + val bufferedOutput = new BufferedOutputStream(zipOut) zipOut.putNextEntry(new ZipEntry("emf-contents")) try { - writeContents(resource, zipOut) + writeContents(resource, bufferedOutput) } finally { + bufferedOutput.flush zipOut.closeEntry } zipOut.putNextEntry(new ZipEntry("resource-description")) try { - writeResourceDescription(resource, zipOut) + writeResourceDescription(resource, bufferedOutput) } finally { + bufferedOutput.flush zipOut.closeEntry } if (storeNodeModel) { zipOut.putNextEntry(new ZipEntry("node-model")) try { - writeNodeModel(resource, zipOut) + writeNodeModel(resource, bufferedOutput) } finally { + bufferedOutput.flush zipOut.closeEntry } } @@ -89,11 +95,12 @@ import org.eclipse.xtext.nodemodel.serialization.SerializationConversionContext } override saveEObject(InternalEObject internalEObject, Check check) throws IOException { + beforeSaveEObject(internalEObject, this) super.saveEObject(internalEObject, check) handleSaveEObject(internalEObject, this) } - + } try { out.saveResource(storageAwareResource) @@ -102,6 +109,10 @@ import org.eclipse.xtext.nodemodel.serialization.SerializationConversionContext } } + protected def beforeSaveEObject(InternalEObject object, EObjectOutputStream writable_1) { + // do nothing + } + protected def void handleSaveEObject(InternalEObject object, BinaryResourceImpl.EObjectOutputStream out) { // do nothing }