That is what I said: binary formats are superior.dangi12012 wrote: ↑Fri Nov 12, 2021 1:24 pmParsing with 500kb/s or 500MB/s makes a difference.
One is the first implementation - the other one would be an optimized parser.
If its binary - we wouldnt need to parse anything and could mount it as a memory mapped file into the memory space directly.
XBoard has a move parser that is quie a bit more clever than just parsing SAN. It also understands PSN (like P-7g), Shogi kifu, Xiangqi notation. And it would all be very fast, if it were not for the stupid back-end: the move generator it calls for disambiguating the moves is called too often, and quite slow. It used to be worse before (generating all fully legal moves always). At least I reduced that to only generating pseudo-legals of the pieces of the indicated type, and only test legality when this is ambiguous.
But for orthodox Chess the disambiguation can be lightning fast. Just keep a piece list, holding the locations of pieces of each type as a stack. For each piece of the indicated type, just test whether the listed piece satisfies any provided disambiguators, and has a pseudo-legal move to the given to-square on an empty board (from a table indexed by the square difference). Only if multiple pieces match you have to do more.