Skip to content

Parser.Parse takes around 18s to parse the 58K file #22

Description

@Metalnem

Parser.Parse takes around 18s to parse the 58K file from the attached archive. You can run the following code to reproduce it (the path variable should contain the path to the extracted file):

var text = File.ReadAllText(path);
var parser = new Parser(new Lexer());
parser.Parse(new Source(text));

Found via SharpFuzz.

Activity

  1. sungam3r commented on Mar 7, 2019

    @sungam3r
    Member

    I can not read the file from the archive. It looks like it has binary data.

  2. sungam3r commented on Mar 8, 2019

    @sungam3r
    Member

    Oh, I get it. The whole point is that the file is binary and its parsing error occurs. Time is wasted on getting an error message in this method, which makes numerous extremely inefficient string replacement calls.

  3. added a commit that references this issue on Mar 8, 2019
    14dea5b
  4. sungam3r commented on Mar 8, 2019

    @sungam3r
    Member

    My explanation was incorrect. The point is not even in allocations, but in the fact that the iterator for each character in the source line called Replace method, which in turn again ran over the entire line. In any case, now there are no such problems.

  5. added a commit that references this issue on Feb 4, 2026
    9b8937d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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