Você está perdendo oportunidades de negociação:
- Aplicativos de negociação gratuitos
- 8 000+ sinais para cópia
- Notícias econômicas para análise dos mercados financeiros
Registro
Login
Você concorda com a política do site e com os termos de uso
Se você não tem uma conta, por favor registre-se
Thank you for the detailed review . Your points pushed the library forward. Here is the technical breakdown of what shipped in v3.4.0:
Adopted Optimizations
1. Zero-Allocation Serialization (No more strings)
You were absolutely right about IntegerToString() creating temporary MQL strings that pressure the GC. I implemented PutRawInteger and PutRawDouble to write digits directly into the byte buffer.
// Old (Heap Allocation): PutRaw(IntegerToString(GetInt(idx)), out, pos, cap); // New v3.4.0 (Zero-Alloc, Direct Buffer Write): void PutRawInteger(long value, uchar &out[], int &pos, int &cap) { // ... writes bytes '0'-'9' directly to out[] ... }2. Hybrid Long/Double Parsing + Exp10 Table
I adopted your idea of accumulating integers as long (faster ALU ops) and using a lookup table for the fractional part (better FP precision). However, I added safety guards that were missing in your snippet:
// My implementation of your suggestion (with safety): if (use_long && int_val < 922337203685477580) { // LONG_MAX / 10 int_val = int_val * 10 + (c - '0'); } else { // Overflow guard: Fallback to double if number > 19 digits if (use_long) { val = (double)int_val; use_long = false; } val = val * 10.0 + (c - '0'); }This gives us the speed of integers for 99.9% of cases, but safely handles massive numbers (e.g. 30-digit bigints) without silent overflow.
Rejected Suggestions (and why)
1. Using c > '9' as delimiter
This weakens RFC 8259 compliance. An input like 123abc would be silently accepted as 123 . I kept the explicit checks:
2. Removing & 0xFF from GetType()
It is not redundant. long in MQL5 is signed. If the tape value has the 63rd bit set (large offset), >> 56 performs an arithmetic shift, filling the high bits with 1s. The mask is required for correctness.
3. Hoisting if (i > 0) outside the loop
The CPU branch predictor handles this pattern (1 miss per loop) with negligible cost (~15 cycles). It does not justify code duplication.
v3.4.0 is now live. Thanks for the collaboration.
Rejected Suggestions (and why)
1. Using c > '9' as delimiter
This weakens RFC 8259 compliance. An input like 123abc would be silently accepted as 123 . I kept the explicit checks:
The RFC 8259 compliance argument is about Robustness Principle (Postel's Law) vs. Strictness for data interchange.
Ref: RFC 8259, Section 6 (Numbers)
The grammar is defined as:
The grammar does not allow trailing characters like 'a', 'b', '-', etc. A value like 123abc is not a number. It is a malformed token.
If the parser uses c > '9' as a stop condition, it consumes 123 and leaves abc in the buffer. In a high-speed parser, this behavior is ambiguous:
By enforcing c == '.' || c == 'e' || c == 'E' , we explicitly state: "These are the ONLY valid continuations for a number." Anything else triggers an immediate check against the structural delimiters ( , } ] or whitespace) in the caller loop, or errors out instantly.
It is a design choice: Fail Fast vs. Fail Later. For financial data (prices/volumes), I prioritize Failing Fast on any ambiguity over saving 1 CPU cycle per digit.
Hope that clarifies better!
Hope that clarifies better!
We're talking about the parser only in FastAtof , where the length n_len is already known. Therefore, my condition can't create even the slightest problem.
You are absolutely right. Since n_len is already determined by the parser before calling FastAtof , the limits are strictly controlled, so the condition you suggested ( c > '9' ) is indeed safe and cannot cause problems.
I applied its optimization in the latest version (v3.4.2). To verify the impact on performance and ensure robustness, I ran a live benchmark test using real market data from the Binance API (OHLCV, Depth, Trades) against `JAson`. The results confirm that the analyzer is stable and incredibly fast.
Environment: MetaTrader 5 build 5614, Intel Core i7-10750H @ 2.60GHz
100 candles x 12 fields
100 levels (Nested arrays)
100 exchanges (Various items)
Thanks again for insisting on the details. The code is cleaner and faster now.
🔗 Updated repository: GitHub/Forge
the condition you suggested ( c > '9' ) is indeed safe and cannot cause problems.
Interesting result.
Result.
Therefore, double checking can be replaced with single checking.
Result.
It would make sense to create a counter for each condition.
On numbers you do a double pass through the array.
Fórum de negociação, sistemas de negociação automatizados e testes de estratégias de negociação
Bibliotecas: JSON Library for LLMs
fxsaber, 2026.02.19 09:02
A more versatile option.Ideal.