* Remove unnecessary ToArray call.
* Remove Value property.
One use compares with null, so cast to T is a waste.
This leaves just one other use, so it can be inlined.
* Remove _dontFallbackFirst
Is always true. Remove it and branches for it being false.
* Don't use Expression.Convert to reference types to object.
The end-result is a no-op, so don't waste the allocation.
If Operator is Exists or leftResults is empty don't obtain rightResults,
as not relevant.
Otherwise if rightResults is not an ICollection<JToken> load it into an
List so it won't be recomputed on each enumeration of leftResults.
otherValue == null, including obj == null, both result in false and
will also result in false if continued into the Equals(JValue) method
in the first branch, so having separate branches is just extra work.
With Null and Undefined BsonValue's, one such value is
indistinguishable from another, so singletons can be used for them,
reducing allocations.
With BsonValue containing booleans as well as there being only so
there's a similar advantage with the extra benefit that if there is
only one true value then a reference-equals check can be used instead
of unboxing to determine the value to write.
Branch on key being null or not once, rather than once per loop.
Remove up-cast of token to JToken to allow jitter to either elide
JValue path if impossible or turn into null-test when inevitable.
Replace is-and-cast with as-and-null-test for quicker cast in cases
where cast is still done.
Running a spell checker on the whole solution revealed a couple more
typos. This fixes all of those (although internal // line comments are
mostly left alone).
Additionally, convert a very few string.Format occurrences to the pre-
dominant .FormatWith pattern and fix some incorrect message strings.
Primarily where it means one fewer field-access or simplifies
event delegate invocation, though one or two cases have just the
lesser advantage of allowing an IL stack dup rather than local access.
BsonBinaryWriter._largeByteBuffer is lazily-allocated, but a path
following the allocation doesn't use it. Move the allocation into the
path that makes use of it, to avoid the null-check and potentially the
allocation.
XML documentation comments for JsonReader, JsonWriter and derived
classes often mention "underlying streams". In most cases however,
these types don't operate directly on Streams, but through other types
such as TextReader and TextWriter.
This commit changes these comments to reflect more accurately what
kind of objects the various JSON reader / writer classes operate on.
Additionally the effect of JsonReader.CloseInput and JsonWriter.Close-
Output is made more explicit in the comments for the Close methods.
* Add references to types where they are missing.
* Fix incorrect references to closed generic types.
* Convert member ID strings to proper references where they can be
converted without breaking the build. The remaining member ID
strings usually mean that the comment would have to be rephrased
for at least one build target / platform.
* Drop namespaces from type names where they are unnecessary.
* Fix the odd typo and add additional <c> markup in a few places.