Bibliotecas: JSON Library for LLMs - página 4

 

I assume that in MQL5, due to the forced check for array out-of-bounds, this condition will be executed slower than the following one.

} else if (((с ^ '0') <= 9) || (c == '-')) {
 
Hi @fxsaber,

Man, these are fantastic suggestions. I really appreciate you taking the time to dig into the source code and point out where we could squeeze more performance.

You were absolutely right about the array bounds check overhead in MQL5. Even though g_cc is fast, the compiler's safety checks add up in a tight loop. I've scrapped the table lookup for digits and implemented your bitwise ALU check (c ^ '0') <= 9 . It’s cleaner and definitely faster.

I also took your advice on the number parsing and rewrote it to be Single-Pass. Now it consumes digits directly into the accumulator and only switches to float logic if it hits a decimal point or exponent. No more double-scanning.

Plus, I reordered the main loop branches to prioritize Strings ( " ) and Numbers, which should help with CPU branch prediction since those are the most common tokens.

Thanks again for the push. The library is significantly better because of your inputs!

🔗 v3.5.0 is live: GitHub/Forge

 
Speeded up parsing by ~10%.
Arquivos anexados:
fast_json2.mqh  40 kb
fast_json3.mqh  40 kb