[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
This commit is contained in:
Sven Efftinge 2015-02-10 16:24:54 +01:00
parent 38bbe3ddb1
commit 8971b90c86

View file

@ -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
}