Skip to content

Commit b892974

Browse files
committed
Reimplement BitArray.Reverse
BitArray.Reverse now returns a BitArray and is implemented using Array.Reverse rather than with a for loop.
1 parent b9c71fd commit b892974

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/DotNetLightning.Core/Utils/Extensions.fs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,10 @@ type System.Collections.BitArray with
148148
BitArray.From5BitEncoding(b)
149149

150150
member this.Reverse() =
151-
let length = this.Length
152-
let mutable result = Array.zeroCreate length
153-
for i in 0 .. (length - 1) do
154-
result.[i] <- this.[length - i - 1]
155-
result
151+
let boolArray: array<bool> = Array.ofSeq (Seq.cast this)
152+
Array.Reverse boolArray
153+
BitArray(boolArray)
154+
156155
member this.PrintBits() =
157156
let sb = StringBuilder()
158157
for b in this do

0 commit comments

Comments
 (0)