Skip to content

Commit

Permalink
micro optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
dj-nitehawk committed Jun 28, 2021
1 parent 1124a9e commit f5b5afb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions MongoDB.Entities/Commands/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ public Update<T> WithArrayFilter(string filter)

options.ArrayFilters =
options.ArrayFilters == null
? new List<ArrayFilterDefinition>() { def }
: options.ArrayFilters.Concat(new List<ArrayFilterDefinition> { def });
? new[] { def }
: options.ArrayFilters.Concat(new[] { def });

return this;
}
Expand Down
4 changes: 2 additions & 2 deletions MongoDB.Entities/Commands/UpdateAndGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ public UpdateAndGet<T, TProjection> WithArrayFilter(string filter)

options.ArrayFilters =
options.ArrayFilters == null
? new List<ArrayFilterDefinition>() { def }
: options.ArrayFilters.Concat(new List<ArrayFilterDefinition> { def });
? new[] { def }
: options.ArrayFilters.Concat(new[] { def });

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion MongoDB.Entities/Core/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void Init(
resume = autoResume;
cancelToken = cancellation;

var ops = new List<ChangeStreamOperationType>() { ChangeStreamOperationType.Invalidate };
var ops = new List<ChangeStreamOperationType>(3) { ChangeStreamOperationType.Invalidate };

if ((eventTypes & EventType.Created) != 0)
ops.Add(ChangeStreamOperationType.Insert);
Expand Down
5 changes: 3 additions & 2 deletions MongoDB.Entities/MongoDB.Entities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
<Description>A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management.</Description>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://mongodb-entities.com</PackageProjectUrl>
<Version>20.16.0-beta4</Version>
<Version>20.16.0-beta5</Version>
<Copyright>Đĵ ΝιΓΞΗΛψΚ</Copyright>
<PackageReleaseNotes>- added DB.InsertAsync() method
- added method for deleting join collections
- optimized internal performance by using lists instead of hashsets
- optimized Cache&lt;T&gt; class
- optimized Watcher class</PackageReleaseNotes>
- optimized Watcher class
- various other minor performance optimizations</PackageReleaseNotes>
<PackageId>MongoDB.Entities</PackageId>
<Product>MongoDB.Entities</Product>
<RepositoryUrl>https://github.com/dj-nitehawk/MongoDB.Entities</RepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion MongoDB.Entities/Relationships/Many.Add.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Task AddAsync(IEnumerable<string> childIDs, IClientSessionHandle session
{
parent.ThrowIfUnsaved();

var models = new List<WriteModel<JoinRecord>>();
var models = new List<WriteModel<JoinRecord>>(childIDs.Count());
foreach (var cid in childIDs)
{
cid.ThrowIfUnsaved();
Expand Down

0 comments on commit f5b5afb

Please sign in to comment.