Skip to content

optimize PGN parsing process and improve perfomance#133

Open
TaehyeonEntus wants to merge 5 commits into
bhlangonijr:masterfrom
TaehyeonEntus:master
Open

optimize PGN parsing process and improve perfomance#133
TaehyeonEntus wants to merge 5 commits into
bhlangonijr:masterfrom
TaehyeonEntus:master

Conversation

@TaehyeonEntus

@TaehyeonEntus TaehyeonEntus commented Mar 21, 2026

Copy link
Copy Markdown

[perf: replace StringBuffer with StringBuilder]

  • It can be a non-thread safe, but it was a StringBuffer
  • All mutable strings in this project are StringBuilder, I think you didn't do it on purpose

[perf: reduce String objects in parsePgnProperty]

  • It had 5 subStrings before, but I reduced 3 of it with using indexOf

[perf: replace pattern matcher with boolean expressions]

  • Pattern matching was too heavy to filter isProperty, so i replace it with 4 boolean expressions
  • It's faster especially parsing moveText, they could be filtered with the first boolean expression

[perf: replace int depth with boolean value in isEndGame]

  • I added a boolean field to check whether pgn line is in a comment
  • It returns true when the comment is closed and ends with a result

I passed every test cases.

PS . Always thanks for your library!!

TaehyeonEntus and others added 5 commits March 21, 2026 21:28
The previous isEndGame only invoked updateCommentState when the current
line already ended with a result token, so a '{' opening a multi-line
comment on a non-result line was never recorded. A subsequent line
ending in 1-0/0-1/1/2-1/2/* would then be treated as the game end even
though it sat inside the open comment.

Update the state unconditionally and short-circuit when a comment is
open. Also guard the '}' branch so a stray closer outside a comment
cannot flip state. Adds two regression tests for multi-line comments
spanning result tokens.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants