Repository navigation
Allow to build LexBuffer from array without copying. - #4882
KevinRansom merged 3 commits into
Conversation
All usages of FromChars seem to be taking a throw away array that caller don't keep a reference, usages found: src\fsharp\lex.fsl(155) src\fsharp\UnicodeLexing.fs(18) src\fsharp\UnicodeLexing.fs(68) src\fsharp\FSharp.Compiler.Private\lex.fs(154) tests\FSharp.Compiler.UnitTests\HashIfExpression.fs(71)
|
|
||
| // A full type signature is required on this method because it is used at more specific types within its own scope | ||
| static member FromArray (s: 'Char[]) : LexBuffer<'Char> = | ||
| // Important: This method takes ownership of the array |
| // Important: This method takes ownership of the array | ||
| static member FromArrayNoCopy (buffer: 'Char[]) : LexBuffer<'Char> = | ||
| let lexBuffer = new LexBuffer<'Char>(fun _ -> ()) | ||
| let buffer = Array.copy s |
There was a problem hiding this comment.
please remove the ; while you are touching this
There was a problem hiding this comment.
Done, were left due to oversight.
| @@ -65,6 +65,7 @@ type internal LexBuffer<'Char> = | |||
| member IsPastEndOfStream: bool with get,set | |||
|
|
|||
There was a problem hiding this comment.
FromArryNoCopy should go here
There was a problem hiding this comment.
Notice that FromArray isn't exposed in this file, this is why I haven't added the extra method.
| lexBuffer | ||
|
|
||
| static member FromChars (arr:char[]) = LexBuffer.FromArray arr | ||
| // A full type signature is required on this method because it is used at more specific types within its own scope |
There was a problem hiding this comment.
I think the comment about full signature can go.
There was a problem hiding this comment.
Waiting for further confirmation, if I should remove all the same comments on the two other methods as well.
Notice that there are dubious comments here:
It doesn't look like those comments apply as the stream is totally handled within the method and we just return the LexBuffer object.
There was a problem hiding this comment.
Yeah those comments look old
|
I have no clue if this failing test is broken because of the change: If it is, I'd somewhat expect more tests to be broken, not just one. |
|
The failing test is this one: |
|
@smoothdeveloper I think that may have been a transient failure due to timing. I was worried the recent control.fs cleanup had caused it but the test is passing on my machine |
|
@dotnet-bot test Windows_NT Release_ci_part2 Build please |
* Allow to build LexBuffer from array without copying. All usages of FromChars seem to be taking a throw away array that caller don't keep a reference, usages found: src\fsharp\lex.fsl(155) src\fsharp\UnicodeLexing.fs(18) src\fsharp\UnicodeLexing.fs(68) src\fsharp\FSharp.Compiler.Private\lex.fs(154) tests\FSharp.Compiler.UnitTests\HashIfExpression.fs(71) * remove spurious semicolons in FromArrayNoCopy * removing spurious comments
All usages of FromChars seem to be taking a throw away array that caller don't keep a reference, usages found:
src\fsharp\lex.fsl(155)
src\fsharp\UnicodeLexing.fs(18)
src\fsharp\UnicodeLexing.fs(68)
src\fsharp\FSharp.Compiler.Private\lex.fs(154)
tests\FSharp.Compiler.UnitTests\HashIfExpression.fs(71)