Hi,
Przemyslaw Czerpak wrote:
There is one trick which can be used to optimize your code.
Instead of allocating new item hb_itemNew() and releasing them by
hb_itemRelease() you can use item on HVM stack.
Just simply add at the beginning of your function:
pKey = hb_stackAllocItem();
You can release it before return by hb_stackPop() but you can also leave
this job to HVM. It will make it automatically restoring function frame.
I was thinking about another optimisation.
hb_vmPush( pValue );
hb_vmPush( pSelf );
for( i = 1; i <= iPCount; i++ )
{
hb_vmPush( hb_stackItemFromBase( i ) );
}
hb_vmProc( ( USHORT ) iPCount );
Can it be changed to? :
hb_itemCopy( hb_stackBaseItem(), pValue )
hb_vmProc( ( USHORT ) iPCount );
or even:
// The same without hb_stackNewFrame() call
hb_itemCopy( hb_stackBaseItem(), pValue )
HB_VM_EXECUTE( pValue ); // Well, it lacks EG_NOFUNC check
Are these methods OK? Is it OK to create new stack frame using the same
symbol, self and locals? Actually, HB_EXECMSG() is doing it. It calls
hb_vmProc() without re-pushing parameters to stack, and both frames uses
the same stack area. Is it OK?
Regards,
Mindaugas
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour