mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Bug 565553 - Improve performance of build command parsers with large number of files
Do not pretty-format *.language.settings.xml files in the workspace plugin state area. These are not meant to be shared and looked by users so they do not really need to be pretty-formatted. This saves a lot of time for large projects with per-file language settings. For example, I have seen this save 30 sec on a test project during serialization. Change-Id: I27f8e0cfdc593f084d95bbed7aedb707570f1f6d Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
This commit is contained in:
parent
2b67c0bda9
commit
b87c2a793d
2 changed files with 24 additions and 12 deletions
|
@ -40,7 +40,6 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
import org.eclipse.cdt.internal.core.XmlUtil;
|
import org.eclipse.cdt.internal.core.XmlUtil;
|
||||||
import org.eclipse.cdt.internal.core.model.Util;
|
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings;
|
import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
|
import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.SettingsModelMessages;
|
import org.eclipse.cdt.internal.core.settings.model.SettingsModelMessages;
|
||||||
|
@ -588,11 +587,7 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
serializingLockWsp.acquire();
|
serializingLockWsp.acquire();
|
||||||
String eol = Util.getLineSeparator(uriStoreWsp);
|
XmlUtil.serializeXml(doc, uriStoreWsp);
|
||||||
if (eol == null) {
|
|
||||||
eol = Util.getDefaultLineSeparator();
|
|
||||||
}
|
|
||||||
XmlUtil.serializeXml(doc, uriStoreWsp, eol);
|
|
||||||
// manufacture events while inside the lock
|
// manufacture events while inside the lock
|
||||||
events = createLanguageSettingsChangeEvents(broadcastingWorkspaceProviders);
|
events = createLanguageSettingsChangeEvents(broadcastingWorkspaceProviders);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -915,11 +910,7 @@ public class LanguageSettingsProvidersSerializer {
|
||||||
if (isWorkspaceStoreEmpty) {
|
if (isWorkspaceStoreEmpty) {
|
||||||
new java.io.File(uriStoreWsp).delete();
|
new java.io.File(uriStoreWsp).delete();
|
||||||
} else {
|
} else {
|
||||||
String eol = Util.getLineSeparator(uriStoreWsp);
|
XmlUtil.serializeXml(docStoreWsp, uriStoreWsp);
|
||||||
if (eol == null) {
|
|
||||||
eol = Util.getDefaultLineSeparator(project);
|
|
||||||
}
|
|
||||||
XmlUtil.serializeXml(docStoreWsp, uriStoreWsp, eol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// manufacture the event only if serialization was successful
|
// manufacture the event only if serialization was successful
|
||||||
|
|
|
@ -279,6 +279,21 @@ public class XmlUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize XML Document into a file.<br/>
|
||||||
|
* Note: clients should synchronize access to this method.
|
||||||
|
*
|
||||||
|
* @param doc - DOM Document to serialize.
|
||||||
|
* @param uriLocation - URI of the file.
|
||||||
|
*
|
||||||
|
* @throws IOException in case of problems with file I/O
|
||||||
|
* @throws TransformerException in case of problems with XML output
|
||||||
|
*/
|
||||||
|
public static void serializeXml(Document doc, URI uriLocation)
|
||||||
|
throws IOException, TransformerException, CoreException {
|
||||||
|
serializeXmlInternal(doc, uriLocation, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize XML Document into a file.<br/>
|
* Serialize XML Document into a file.<br/>
|
||||||
* Note: clients should synchronize access to this method.
|
* Note: clients should synchronize access to this method.
|
||||||
|
@ -286,18 +301,24 @@ public class XmlUtil {
|
||||||
* @param doc - DOM Document to serialize.
|
* @param doc - DOM Document to serialize.
|
||||||
* @param uriLocation - URI of the file.
|
* @param uriLocation - URI of the file.
|
||||||
* @param lineSeparator - line separator.
|
* @param lineSeparator - line separator.
|
||||||
|
* Note: This will serialize in pretty format
|
||||||
*
|
*
|
||||||
* @throws IOException in case of problems with file I/O
|
* @throws IOException in case of problems with file I/O
|
||||||
* @throws TransformerException in case of problems with XML output
|
* @throws TransformerException in case of problems with XML output
|
||||||
*/
|
*/
|
||||||
public static void serializeXml(Document doc, URI uriLocation, String lineSeparator)
|
public static void serializeXml(Document doc, URI uriLocation, String lineSeparator)
|
||||||
throws IOException, TransformerException, CoreException {
|
throws IOException, TransformerException, CoreException {
|
||||||
|
serializeXmlInternal(doc, uriLocation, lineSeparator);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void serializeXmlInternal(Document doc, URI uriLocation, String lineSeparator)
|
||||||
|
throws IOException, TransformerException, CoreException {
|
||||||
java.io.File storeFile = new java.io.File(uriLocation);
|
java.io.File storeFile = new java.io.File(uriLocation);
|
||||||
if (!storeFile.exists()) {
|
if (!storeFile.exists()) {
|
||||||
storeFile.createNewFile();
|
storeFile.createNewFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
String utfString = toString(doc, lineSeparator);
|
String utfString = lineSeparator != null ? toString(doc, lineSeparator) : toString(doc);
|
||||||
|
|
||||||
FileOutputStream output = getFileOutputStreamWorkaround(storeFile);
|
FileOutputStream output = getFileOutputStreamWorkaround(storeFile);
|
||||||
output.write(utfString.getBytes(ENCODING_UTF_8));
|
output.write(utfString.getBytes(ENCODING_UTF_8));
|
||||||
|
|
Loading…
Add table
Reference in a new issue