Skip to content

Commit b0eec76

Browse files
author
rstam
committed
Code review changes.
1 parent 8b1758a commit b0eec76

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

MongoDB.Driver/AggregateArgs.cs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,7 @@ public AggregateOutputMode OutputMode
114114
public IEnumerable<BsonDocument> Pipeline
115115
{
116116
get { return _pipeline; }
117-
set { _pipeline = value; }
118-
}
119-
120-
// internal methods
121-
internal AggregateArgs WithMaterializedPipeline()
122-
{
123-
if (_pipeline is BsonDocument[] || _pipeline is List<BsonDocument>)
124-
{
125-
return this;
126-
}
127-
128-
var materializedPipeline = _pipeline.ToArray();
129-
return new AggregateArgs
130-
{
131-
AllowDiskUse = _allowDiskUse,
132-
BatchSize = _batchSize,
133-
MaxTime = _maxTime,
134-
OutputMode = _outputMode,
135-
Pipeline = materializedPipeline
136-
};
117+
set { _pipeline = value.ToList(); }
137118
}
138119
}
139120
}

MongoDB.Driver/MongoCollection.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public virtual IEnumerable<BsonDocument> Aggregate(AggregateArgs args)
125125
if (args == null) { throw new ArgumentNullException("args"); }
126126
if (args.Pipeline == null) { throw new ArgumentException("Pipeline is null.", "args"); }
127127

128-
args = args.WithMaterializedPipeline(); // materialize the pipeline if necessary to prevent double enumeration side effects
129128
var lastStage = args.Pipeline.LastOrDefault();
130129

131130
string outputCollectionName = null;
@@ -1725,7 +1724,7 @@ public ReadOnlyCollection<IEnumerator> ParallelScanAs(Type documentType, Paralle
17251724
var methodInfo = methodDefinition.MakeGenericMethod(documentType);
17261725
try
17271726
{
1728-
return new ReadOnlyCollection<IEnumerator>(((IEnumerable)methodInfo.Invoke(this, new object[] { args })).Cast<IEnumerator>().ToList());
1727+
return ((IEnumerable)methodInfo.Invoke(this, new object[] { args })).Cast<IEnumerator>().ToList().AsReadOnly();
17291728
}
17301729
catch (TargetInvocationException ex)
17311730
{

MongoDB.Driver/Operations/ParallelScanOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public ReadOnlyCollection<IEnumerator<TDocument>> Execute(MongoConnection connec
114114
enumerators.Add(enumerator);
115115
}
116116

117-
return new ReadOnlyCollection<IEnumerator<TDocument>>(enumerators);
117+
return enumerators.AsReadOnly();
118118
}
119119
}
120120
}

0 commit comments

Comments
 (0)