From 3a5a44f7d5e1ab811e9427eccd9e2d4220a686c0 Mon Sep 17 00:00:00 2001 From: Maxime Porhel Date: Wed, 17 Apr 2024 11:49:55 +0200 Subject: [PATCH] Do not checkDuplicates when adding resource in new folder #70 - Do not checkDuplicates for addition of non loaded TRANSIENT resource (just created) in NEW folder (non committed yet)but just invalidate resourcePath cache. - Undo/redo of creation/deletion scenario are not impacted: newNode is a loaded resource. This optimize the export scenario which has a +20% time degradation with 330 diagrams (60 to 84s). Change-Id: I40e74a4f34de84bfb3ca4570af66610c594a1838 Signed-off-by: Maxime Porhel --- .../eresource/impl/CDOResourceFolderImpl.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java index fd53f5a97ec..4e5098ad8e8 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2012, 2015, 2016, 2018, 2019, 2022 Eike Stepper (Loehne, Germany) and others. + * Copyright (c) 2008-2012, 2015, 2016, 2018, 2019, 2022, 2024 Eike Stepper (Loehne, Germany) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,9 +7,11 @@ * * Contributors: * Eike Stepper - initial API and implementation + * Obeo - Perf optimizations */ package org.eclipse.emf.cdo.eresource.impl; +import org.eclipse.emf.cdo.CDOState; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDOList; import org.eclipse.emf.cdo.common.util.CDODuplicateResourceException; @@ -139,8 +141,22 @@ protected EList createList(EStructuralFeature eStructuralFeature) throws CDOD protected CDOResourceNode validate(int index, CDOResourceNode newNode) { String newPath = getPath() + CDOURIUtil.SEGMENT_SEPARATOR + newNode.getName(); - CDOResourceFolderImpl.this.checkDuplicates(newPath); + if (newNode instanceof CDOResource + && !((CDOResource)newNode).isLoaded() + && CDOState.TRANSIENT.equals(newNode.cdoState()) + && CDOState.NEW.equals(CDOResourceFolderImpl.this.cdoState())) + { + InternalCDOView view = cdoView(); + if (view != null) + { + view.clearResourcePathCacheIfNecessary(null); + } + } + else + { + CDOResourceFolderImpl.this.checkDuplicates(newPath); + } return super.validate(index, newNode); } };