PB wrote:Don't make the size too big, because the bigger the buffer,
the slower your string routines will perform.
I dont think thats correct. The speed has nothing to do with
the string buffer size IMO, but with the actual length of the string.
If you set the buffer to 20MB and use 10-char-strings only, its
not slower. Its slower if you use 20MB strings, yes... logical
PB wrote:Code: Select all
; Now assign a string to be exactly 1048576 bytes (1 MB).
a$="s"+Space(1048574)+"e"
Thats not correct because the string buffer includes the ending 0 (ASCIIZ).
If you set the string buffer to 1.000.000, you can only use strings
with size 999.999.
If you use bigger sizes, other memory gets overwritten and result
is undefined. Sometimes it crashes, sometimes it works - but still
other memory got overwritten by your code sample.
Anyway, this trick doesnt work with some functions:
Code: Select all
Procedure SetStringManipulationBufferSize(Bytes)
PBStringBase.l = 0
PBMemoryBase.l = 0
!MOV eax, dword [PB_StringBase]
!MOV [esp+4],eax
!MOV eax, dword [PB_MemoryBase]
!MOV [esp+8],eax
HeapReAlloc_(PBMemoryBase, #GMEM_ZEROINIT, PBStringBase, Bytes)
!MOV dword [_PB_StringBase],eax
EndProcedure
; Set the buffer size for all strings to 1 MB.
SetStringManipulationBufferSize(1048576)
A$ = Space(1000000)+"abc d "
; CRASH 1 - ReplaceString()
A$ = ReplaceString(A$,"abc","def")
; CRASH 2 - RemoveString()
A$ = RemoveString(A$,"abc")
; DOESNT WORK - PeekS() (or debugger?)
mem = AllocateMemory(1,1000000,0)
*mem.LONG = mem
For a = 1 To 1000000/4
*mem\l = '4321'
*mem + 4
Next a
Debug PeekS(mem,$FFFF) ; 65k max, works
Debug PeekS(mem) ; doesnt return a string
Debug PeekS(mem,66000) ; doesnt return a string
I have seen other things that dont work correctly with this
system, but cant remember anymore atm (i think it was together
with EditorGadget or another Gadget and GetGadgetText() function).
Did somebody try ReadString() and WriteStringN() with big strings,
lets say 1MB? I dont want to test this...
