File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
OWLSharp/Ontology/Expressions Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -60,16 +60,21 @@ public static T ToEntity<T>(this RDFResource iri) where T : IOWLEntity
6060 /// </summary>
6161 internal static List < T > RemoveDuplicates < T > ( List < T > expressions ) where T : OWLExpression
6262 {
63- List < T > deduplicatedExpressions = new List < T > ( ) ;
64- if ( expressions ? . Count > 0 )
63+ #region Guards
64+ if ( expressions == null || expressions . Count == 0 )
65+ return new List < T > ( ) ;
66+ #endregion
67+
68+ #if NET8_0_OR_GREATER
69+ HashSet < long > lookup = new HashSet < long > ( expressions . Count ) ;
70+ #else
71+ HashSet < long > lookup = new HashSet < long > ( ) ;
72+ #endif
73+ List < T > deduplicatedExpressions = new List < T > ( expressions . Count ) ;
74+ foreach ( T expression in expressions )
6575 {
66- HashSet < long > lookup = new HashSet < long > ( ) ;
67- expressions . ForEach ( expression =>
68- {
69- long expressionID = expression . GetIRI ( ) . PatternMemberID ;
70- if ( lookup . Add ( expressionID ) )
71- deduplicatedExpressions . Add ( expression ) ;
72- } ) ;
76+ if ( lookup . Add ( expression . GetIRI ( ) . PatternMemberID ) )
77+ deduplicatedExpressions . Add ( expression ) ;
7378 }
7479 return deduplicatedExpressions ;
7580 }
You can’t perform that action at this time.
0 commit comments