11// Lucene version compatibility level 4.8.1
22using Lucene . Net . Diagnostics ;
3+ using Lucene . Net . Index ;
34using Lucene . Net . Support ;
45using Lucene . Net . Support . Threading ;
56using System ;
7+ using System . Buffers . Binary ;
68using System . Collections . Concurrent ;
79using System . Collections . Generic ;
810using System . Runtime . CompilerServices ;
@@ -283,7 +285,7 @@ private static void CheckSeen(ISet<string> seenDims, string dim)
283285 /// (<see cref="FacetField"/> or <see cref="AssociationFacetField"/>).
284286 ///
285287 /// <para>
286- /// <b>NOTE:</b> you should add the returned document to <see cref="Index. IndexWriter"/>, not the
288+ /// <b>NOTE:</b> you should add the returned document to <see cref="IndexWriter"/>, not the
287289 /// input one!
288290 /// </para>
289291 /// </summary>
@@ -297,7 +299,7 @@ public virtual Document Build(Document doc)
297299 /// Translates any added <see cref="FacetField"/>s into normal fields for indexing.
298300 ///
299301 /// <para>
300- /// <b>NOTE:</b> you should add the returned document to <see cref="Index. IndexWriter"/>, not the
302+ /// <b>NOTE:</b> you should add the returned document to <see cref="IndexWriter"/>, not the
301303 /// input one!
302304 /// </para>
303305 /// </summary>
@@ -530,11 +532,17 @@ private static void ProcessAssocFacetFields(ITaxonomyWriter taxoWriter, IDiction
530532 {
531533 bytes = ArrayUtil . Grow ( bytes , upto + 4 ) ;
532534 }
533- // big-endian:
534- bytes [ upto ++ ] = ( byte ) ( ordinal >> 24 ) ;
535- bytes [ upto ++ ] = ( byte ) ( ordinal >> 16 ) ;
536- bytes [ upto ++ ] = ( byte ) ( ordinal >> 8 ) ;
537- bytes [ upto ++ ] = ( byte ) ordinal ;
535+
536+ // // big-endian:
537+ // bytes[upto++] = (byte)(ordinal >> 24);
538+ // bytes[upto++] = (byte)(ordinal >> 16);
539+ // bytes[upto++] = (byte)(ordinal >> 8);
540+ // bytes[upto++] = (byte)ordinal;
541+
542+ // LUCENENET: Use BinaryPrimitives for JIT-intrinsics opportunity
543+ BinaryPrimitives . WriteInt32BigEndian ( bytes . AsSpan ( upto , sizeof ( int ) ) , ordinal ) ;
544+ upto += sizeof ( int ) ;
545+
538546 if ( upto + field . Assoc . Length > bytes . Length )
539547 {
540548 bytes = ArrayUtil . Grow ( bytes , upto + field . Assoc . Length ) ;
0 commit comments