Skip to content

Commit df7e6d2

Browse files
committed
Removed redundant ContentTypeDescriptor update in Save()
The `Save()` method currently has two places where it updates the `_ContentTypeDescriptors` cache. This is redundant, and means the second one—which is actually more cautious—will never actually fire. To avoid this, I've removed the first one. While I was at it, I also updated the second one to use pattern matching syntax for the variable definition, which is a bit less code, and easier to read.
1 parent 78a9d3f commit df7e6d2

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

OnTopic/Repositories/TopicRepositoryBase.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,6 @@ public virtual int Save([ValidatedNotNull, NotNull]Topic topic, bool isRecursive
320320
);
321321
}
322322

323-
/*------------------------------------------------------------------------------------------------------------------------
324-
| Update content types collection, if appropriate
325-
\-----------------------------------------------------------------------------------------------------------------------*/
326-
if (topic is ContentTypeDescriptor && !contentTypeDescriptors.Contains(topic.Key)) {
327-
contentTypeDescriptors.Add((ContentTypeDescriptor)topic);
328-
}
329-
330323
/*------------------------------------------------------------------------------------------------------------------------
331324
| Ensure derived topic is set
332325
>-------------------------------------------------------------------------------------------------------------------------
@@ -364,11 +357,11 @@ public virtual int Save([ValidatedNotNull, NotNull]Topic topic, bool isRecursive
364357
\-----------------------------------------------------------------------------------------------------------------------*/
365358
if (
366359
topic.IsNew &&
367-
topic is ContentTypeDescriptor &&
360+
topic is ContentTypeDescriptor descriptor &&
368361
_contentTypeDescriptors != null &&
369362
!_contentTypeDescriptors.Contains(topic.Key)
370363
) {
371-
_contentTypeDescriptors.Add((ContentTypeDescriptor)topic);
364+
_contentTypeDescriptors.Add(descriptor);
372365
}
373366

374367
/*------------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)