Skip to content

Commit afe7b70

Browse files
committed
Simplified ContentTypeDescriptor update in Delete()
Previously, when deleting a `ContentTypeDescriptor`, the `Delete()` function would identify all descendant `ContentTypeDescriptors` and delete any matches found in the `_contentTypeDescriptors` cache. This code isn't really necessary. A much shorter method is to simply repopulate the `_contentTypeDescriptor` using the new `SetContentTypeDescriptors()` overload (78a9d3f), which will lookup the root `ContentTypeDescriptor` from the topic graph and then recreate the cache without the deleted `ContentTypeDescriptor` (or its children). In addition to being easier to maintain, this method is likely also a touch faster since it doesn't need to find all descendants, compare them against the original collection, and then remove them from teh collection.
1 parent 5941385 commit afe7b70

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

OnTopic/Repositories/TopicRepositoryBase.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,7 @@ public virtual void Delete([ValidatedNotNull, NotNull]Topic topic, bool isRecurs
478478
/*------------------------------------------------------------------------------------------------------------------------
479479
| If content type, remove from cache
480480
\-----------------------------------------------------------------------------------------------------------------------*/
481-
if (topic is ContentTypeDescriptor && _contentTypeDescriptors != null) {
482-
foreach (var contentTypeDescriptor in topic.FindAll(t => t is ContentTypeDescriptor).Cast<ContentTypeDescriptor>()) {
483-
if (_contentTypeDescriptors.Contains(contentTypeDescriptor)) {
484-
_contentTypeDescriptors.Remove(contentTypeDescriptor);
485-
}
486-
}
487-
}
481+
SetContentTypeDescriptors(topic.Parent);
488482

489483
/*------------------------------------------------------------------------------------------------------------------------
490484
| If attribute type, refresh cache

0 commit comments

Comments
 (0)