Skip to content

Commit a0b0a96

Browse files
committed
Removed duplicate null check
The `dto` parameter is already validated as not null in the two cases where `AddToList()` is called. There's no need to validate it again. While I was at it, used `camelCase` for local function name, per emerging convention. (The remaining local functions already use this.)
1 parent 5b4aeee commit a0b0a96

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

OnTopic/Mapping/TopicMappingService.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ configuration.ContentTypeFilter is not null &&
954954
}
955955
}
956956
else {
957-
AddToList(childDto);
957+
addToList(childDto);
958958
}
959959

960960
}
@@ -967,22 +967,20 @@ configuration.ContentTypeFilter is not null &&
967967
var dto = await dtoTask.ConfigureAwait(false);
968968
taskQueue.Remove(dtoTask);
969969
if (dto is not null) {
970-
AddToList(dto);
970+
addToList(dto);
971971
}
972972
}
973973

974974
/*------------------------------------------------------------------------------------------------------------------------
975975
| Function: Add to List
976976
\-----------------------------------------------------------------------------------------------------------------------*/
977-
void AddToList(object dto) {
978-
if (dto is not null) {
979-
try {
980-
targetList.Add(dto);
981-
}
982-
catch (ArgumentException) {
983-
//Ignore exceptions caused by duplicate keys, in case the IList represents a keyed collection
984-
//We would defensively check for this, except IList doesn't provide a suitable method to do so
985-
}
977+
void addToList(object dto) {
978+
try {
979+
targetList.Add(dto);
980+
}
981+
catch (ArgumentException) {
982+
//Ignore exceptions caused by duplicate keys, in case the IList represents a keyed collection
983+
//We would defensively check for this, except IList doesn't provide a suitable method to do so
986984
}
987985
}
988986

0 commit comments

Comments
 (0)