I assume VarSetStrCapacity() is now solely for optimizing string concatenation.
1. Does VarSetStrCapacity() initialize the memory in any way? I checked GitHub, and it doesn't, but I want to be sure.
2. It looks like passing a string to NumPut() is not recommended. The buffer object seems to be preferred. If passing a string were to be removed, would passing the address of the string still work?
3. Is the buffer object faster than VarSetStrCapacity() + RtlZeroMemory?
Questions about DllCall() & VarSetStrCapacity()
Re: Questions about DllCall() & VarSetStrCapacity()
I assume it is for strings, not any other binary data.
1, I assume it initialise a blank string, so puts one zero at the beginning of the buffer.
2, yes
3, probably the last thing to consider.
I couldn't access the varstrcapacity docs
Cheers
1, I assume it initialise a blank string, so puts one zero at the beginning of the buffer.
2, yes
3, probably the last thing to consider.
I couldn't access the varstrcapacity docs
Cheers
Re: Questions about DllCall() & VarSetStrCapacity()
VarSetStrCapacity is the same as VarSetCapacity, aside from:
If you want to know whether something is faster, benchmark it, in the context that matters to you.
- The second parameter and return value are in characters, not bytes.
- No FillByte parameter (acts like it's always omitted).
- VarSetStrCapacity(v) throws an exception if the variable contains a pure number or object.
If you want to know whether something is faster, benchmark it, in the context that matters to you.
Re: Questions about DllCall() & VarSetStrCapacity()
4. Is the buffer object compatible with VarSetStrCapacity? The docs say passing an object should throw... but my code works fine.
Re: Questions about DllCall() & VarSetStrCapacity()
What does compatibility mean in this context? The answer is no though.Is the buffer object compatible with VarSetStrCapacity
no it doesn't, it says,The docs say passing an object should throw
Consequently,An exception is thrown under any of the following conditions:
VarName is not a valid variable reference. It is not possible to pass an object property or built-in variable by reference, and therefore not valid to pass one to this function.
Code: Select all
varsetstrcapacity a:=bufferalloc(1),1 ; yes
varsetstrcapacity bufferalloc(1),1 ; no
Return to “AutoHotkey Development”
Who is online
Users browsing this forum: No registered users and 65 guests