Skip to content

Commit

Permalink
Do not checkDuplicates when adding resource in new folder eclipse-cdo#70
Browse files Browse the repository at this point in the history


- 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 <maxime.porhel@obeo.fr>
  • Loading branch information
mPorhel committed Aug 20, 2024
1 parent cdff677 commit 3a5a44f
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/*
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* 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;
Expand Down Expand Up @@ -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);
}
};
Expand Down

0 comments on commit 3a5a44f

Please sign in to comment.