In the FillHiliteInfo proc, I've replaced all of the GetPrivateProfileString/ParseBuffer statements with a loop. I'll post the new proc below, but what I'm wondering is if there are any advantages in terms of speed or performance using the original method or my loop.

In the .data section I've declared a new table of all of the offsets to the C1-C10 strings. Also I've declared two new vars -- counter and counter2 as dwords of 0's.

FillHiliteInfo proc uses edi ecx esi edx ebx
LOCAL buffer[1024]:BYTE

invoke RtlZeroMemory,addr ASMSyntaxArray,sizeof ASMSyntaxArray
invoke GetModuleFileName,hInstance,addr buffer,sizeof buffer
invoke lstrlen,addr buffer
mov ecx,eax
dec ecx
lea edi,buffer
add edi,ecx
mov al,"\"
repne scasb
inc edi
mov byte ptr [edi],0
invoke lstrcat,addr buffer,addr WordFileName
invoke GetFileAttributes,addr buffer
.if eax != -1
mov BlockSize,1024*10
invoke HeapAlloc,hMainHeap,0,BlockSize
mov pTemp,eax
lea ebx,tblColorKeys
mov counter,1
mov counter2,0
mov ecx,counter
.while ecx <= 10
invoke GetPrivateProfileString,addr ASMSection,[ebx+(ecx*4)],addr ZeroString,pTemp,BlockSize,addr buffer
.if eax != 0
inc eax
.if eax == BlockSize ;the buffer is too small
add BlockSize,1024*10
invoke HeapReAlloc,hMainHeap,0,pTemp,BlockSize
mov pTemp,eax
jmp @B
mov edx,offset ASMColorArray
add edx,counter2
invoke ParseBuffer,hMainHeap,pTemp,eax,edx,addr ASMSyntaxArray
add counter2,4
add counter,1
xor ecx,ecx
mov ecx,counter
xor ecx,ecx
mov counter2,ecx
invoke HeapFree,hMainHeap,0,pTemp
FillHiliteInfo endp

So are there any advantages/disadvantages of doing it this way? I'll be able to add more color keys in the .ini file very simply without having to copy/paste any code. Other than that I guess it just looks cleaner this way. -shrugs-
Posted on 2002-11-01 15:28:52 by Will