Features of the mql5 language, subtleties and tricks - page 162

 
Nikolai Semko:


for structures and classes that include strings or dynamic arrays or class references, sizeof() will point the finger at the sky.

and I can understand it :-)

 
Nikolai Semko:


String type in mql is very complicated, and not fully disclosed in documentation.
But it can be guessed from C language, that char array (buffer) is wrapped in string type
And then you start dancing with understanding how it works ))

 
Roman:

The string type in mql is very tricky, and is not fully disclosed in the documentation.
But the C language suggests that the string type is a char array (buffer)
And then you start dancing with understanding how it works ))

There are no strings in C.

 
Maxim Kuznetsov:

for structures and classes that include strings or dynamic arrays or class references, sizeof() will point the finger at the sky.

and I can understand it :-)

But why?
With any dynamic array it will show the size of the dynamic array object, which is 52 bytes in MQL5


 
Nikolai Semko:

There are no thongs in C.

I think there already is, but that's not the point.
Yes, C has char[], it is wrapped in mql string

 
Nikolai Semko:

But why?
With any dynamic array it will show the size of the dynamic array object, which is 52 bytes in MQL5

the size of what and for whom will it show ?

52 bytes is their internal device only.

Why it's not 64 is unclear, they could have aligned :-)

 
Roman:

I think there already is, but that's not the point.
Yes, C has char[], it is wrapped in mql string

Well, I understand that.
I do not use string functions at all. I immediately convert them to a char array using the StringToCharArray function and then work with the array. I have found it to be much more efficient.

Especially when it comes to parsing.

 
Maxim Kuznetsov:

the size of what and for whom will it show ?

52 bytes is only their internal structure.

It's not clear why it's not 64, they could have aligned it :-)

Probably some kind of structure with different types. For example, 5 ulong and 3 uint. Maybe time is present for internal processing and time of last access. I DON'T KNOW. Who knows what this structure may contain.

 
Nikolai Semko:

Well, that's understandable.
I don't use string functions at all. I immediately convert them to a char array using the StringToCharArray function and then work with the array. I have found it to be much more efficient.

Most likely, the mql string is short[] or wchar_t[] or wchar_t*.
After all, mql strings are in Unicode, while utf is 2 bytes.
And StringToCharArray converts from short[] to char[].

 
Roman:

And most likely under mql string there is short[]
After all, there are 2 bytes in string in Unicode in mql.
And StringToCharArray converts from short[] to char[]

no I would have noticed. Although I don't exclude that in some cases (when working with Unicode) it is possible. In Java, for example, char type is 2 bytes.
I tried to parse data from crypto-exchange in two variants: via this JSON library and via working with char array.
The difference turned out to be 700(!!!) times by speed. I was shocked. Perhaps it was far from the best JSON implementation.

Reason: