Skip to content

String.concat casts to an array before concatenating #2569

@saul

Description

@saul

In String.concat, the elements to concatenate are first passed through Seq.toArray, see:
https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/FSharp.Core/string.fs#L23

String.Join has an overload of IEnumerable, so why are we casting it to an array first? I did some benchmarks for my PR #2558 (comment) and noticed that String.concat is really slow with large sequences. Using String.Join is significantly faster, and I it's because we're doing Seq.toArray first.

@dsyme do you have any comments as to why we convert the sequence to an array first? I wonder if the String.Join overload was added after this function was written.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions