From bb25145a1c2c11bc3481f2f2ddbb94a3eccea874 Mon Sep 17 00:00:00 2001 From: "Alexander S.Kresin" Date: Mon, 21 Jan 2002 07:08:27 +0000 Subject: [PATCH] 2002-01-21 10:10 UTC+0300 Alexander Kresin --- harbour/ChangeLog | 9 ++++ harbour/source/rdd/dbfntx/dbfntx1.c | 80 ++++++++++++++++++++--------- harbour/source/vm/hvm.c | 3 ++ harbour/source/vm/memvars.c | 1 + 4 files changed, 68 insertions(+), 25 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4b5158bae9..65b093c52a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -7,6 +7,15 @@ For example: 2002-12-01 23:12 UTC+0100 Foo Bar */ +2002-01-21 13:42 UTC+0100 Antonio Linares + * source/vm/hvm.c + * if() used at HB_P_FUNCTION to avoid a hb_itemClear() call when not needed + to improve execution speed. + +2002-01-21 13:12 UTC+0100 Antonio Linares + * source/vm/hvm.c + * Improved hb_vmMessage() for execution speed. + 2002-01-21 12:39 UTC+0100 Antonio Linares * source/vm/hvm.c + New hb_vmIncDouble() and hb_DecDouble() used from diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index 7724732500..676fddb060 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -182,6 +182,8 @@ static char * numToStr( PHB_ITEM pItem, char* szBuffer, USHORT length, USHORT de return szBuffer; } +/* Implementation of internal functions */ + static BOOL checkLogicalExpr( PHB_ITEM pForItem, PHB_ITEM pItem ) { HB_MACRO_PTR pMacro; @@ -212,7 +214,17 @@ static BOOL checkLogicalExpr( PHB_ITEM pForItem, PHB_ITEM pItem ) return res; } -/* Implementation of internal functions */ +static ULONG hb_ntxTagKeyNo( LPTAGINFO pTag ) +{ + HB_SYMBOL_UNUSED( pTag ); + return 0; +} + +static ULONG hb_ntxTagKeyCount( LPTAGINFO pTag ) +{ + HB_SYMBOL_UNUSED( pTag ); + return 0; +} static LPKEYINFO hb_ntxKeyNew( LPKEYINFO pKeyFrom ) { @@ -248,22 +260,20 @@ static LONG hb_ntxTagKeyFind( LPTAGINFO pTag, LPKEYINFO pKey, BOOL * result ) K = hb_ntxTagFindCurrentKey( hb_ntxPageLoad( 0 ), pKey->Tag, pKey, FALSE, TRUE, 1 ); if( K == 0 ) { - // if( pTag->pForItem == NULL ) - // { + /* if( pTag->pForItem == NULL ) + { */ *result = TRUE; return pKey->Xtra; - // } - // else - /* TODO: test for expression */ - // pTag->TagEOF = TRUE; + /* } + else + pTag->TagEOF = TRUE; */ } else if( K < 0 ) { - // if( pTag->pForItem == NULL ) + /* if( pTag->pForItem == NULL ) */ return pKey->Xtra; - // else - /* TODO: test for expression */ - // pTag->TagEOF = TRUE; + /* else + pTag->TagEOF = TRUE; */ } else pTag->TagEOF = TRUE; @@ -390,7 +400,6 @@ static USHORT hb_ntxPageFindCurrentKey( LPPAGEINFO pPage, ULONG ulRecno ) static void hb_ntxGetCurrentKey( LPTAGINFO pTag, LPKEYINFO pKey ) { char szBuffer[ NTX_MAX_KEY ]; - /* printf( "\n\rhb_ntxGetCurrentKey - 0: |%s|",pTag->KeyExpr ); */ if( hb_itemType( pTag->pKeyItem ) == HB_IT_BLOCK ) { hb_vmPushSymbol( &hb_symEval ); @@ -779,24 +788,24 @@ static void hb_ntxTagKeyRead( LPTAGINFO pTag, BYTE bTypRead, BOOL * lContinue ) switch( bTypRead ) { case TOP_RECORD: - // if( pTag->pForItem != NULL ) - // printf( "hb_ntxTagKeyRead()" ); - // else + /* if( pTag->pForItem != NULL ) + printf( "hb_ntxTagKeyRead()" ); + else */ pTag->TagBOF = !hb_ntxPageReadTopKey( NULL,0 ); - // if( pTag->pForItem != NULL ) - // printf( "hb_ntxTagTestRange()" ); + /* if( pTag->pForItem != NULL ) + printf( "hb_ntxTagTestRange()" ); */ if( pTag->TagEOF ) pTag->TagBOF = TRUE; pTag->TagEOF = pTag->TagBOF; break; case BTTM_RECORD: - // if( pTag->pForItem != NULL ) - // printf( "hb_ntxTagKeyRead()" ); - // else + /* if( pTag->pForItem != NULL ) + printf( "hb_ntxTagKeyRead()" ); + else */ pTag->TagEOF = !hb_ntxPageReadBottomKey( NULL,0 ); - // if( pTag->pForItem != NULL ) - // printf( "hb_ntxTagTestRange()" ); + /* if( pTag->pForItem != NULL ) + printf( "hb_ntxTagTestRange()" ); */ if( pTag->TagBOF ) pTag->TagEOF = TRUE; pTag->TagBOF = pTag->TagEOF; @@ -2533,8 +2542,8 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) hb_itemCopy( pKeyExp, pExpr ); /* Get a blank record before testing expression */ - // SELF_GOBOTTOM( ( AREAP ) pArea ); - // SELF_SKIP( ( AREAP ) pArea, 1 ); + /* SELF_GOBOTTOM( ( AREAP ) pArea ); + SELF_SKIP( ( AREAP ) pArea, 1 ); */ pExpMacro = pForMacro = NULL; if( hb_itemType( pExpr ) == HB_IT_BLOCK ) { @@ -2644,7 +2653,6 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) hb_itemCopy( pResult, &hb_stack.Return ); } uiType = hb_itemType( pResult ); - // hb_itemRelease( pResult ); if( uiType != HB_IT_LOGICAL ) { hb_itemRelease( pKeyExp ); @@ -2799,6 +2807,28 @@ static ERRCODE ntxOrderInfo( NTXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pInfo case DBOI_BAGEXT: hb_itemPutC( pInfo->itmResult, ".ntx" ); break; + case DBOI_KEYCOUNT: + if( pArea->lpNtxIndex ) + { + pIndex = ntxFindIndex( pArea , pInfo->itmOrder ); + if( pIndex ) + { + hb_itemPutNL( pInfo->itmResult, hb_ntxTagKeyCount( pIndex->CompoundTag ) ); + return SUCCESS; + } + } + break; + case DBOI_POSITION: + if( pArea->lpNtxIndex ) + { + pIndex = ntxFindIndex( pArea , pInfo->itmOrder ); + if( pIndex ) + { + hb_itemPutNL( pInfo->itmResult, hb_ntxTagKeyNo( pIndex->CompoundTag ) ); + return SUCCESS; + } + } + break; } return SUCCESS; } diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 188f225f2b..c4313245ca 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -2608,6 +2608,7 @@ static void hb_vmArrayPop( void ) { if( ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen ) { + pValue->type &= ~HB_IT_MEMOFLAG; hb_arraySet( pArray, ulIndex, pValue ); hb_itemCopy( pArray, pValue ); /* places pValue at pArray position */ hb_stackPop(); @@ -4231,6 +4232,7 @@ static void hb_vmPopLocal( SHORT iLocal ) hb_stackDec(); + hb_stackTopItem()->type &= ~HB_IT_MEMOFLAG; if( iLocal >= 0 ) { /* local variable or local parameter */ @@ -4257,6 +4259,7 @@ static void hb_vmPopStatic( USHORT uiStatic ) HB_TRACE(HB_TR_DEBUG, ("hb_vmPopStatic(%hu)", uiStatic)); hb_stackDec(); + hb_stackTopItem()->type &= ~HB_IT_MEMOFLAG; pStatic = s_aStatics.item.asArray.value->pItems + hb_stack.iStatics + uiStatic - 1; if( HB_IS_BYREF( pStatic ) ) diff --git a/harbour/source/vm/memvars.c b/harbour/source/vm/memvars.c index c9ab5895c4..8812ad4f06 100644 --- a/harbour/source/vm/memvars.c +++ b/harbour/source/vm/memvars.c @@ -438,6 +438,7 @@ void hb_memvarSetValue( PHB_SYMB pMemvarSymb, HB_ITEM_PTR pItem ) */ hb_memvarCreateFromDynSymbol( pDyn, VS_PRIVATE, pItem ); } + s_globalTable[ pDyn->hMemvar ].item.type &= ~HB_IT_MEMOFLAG; } else hb_errInternal( HB_EI_MVBADSYMBOL, NULL, pMemvarSymb->szName, NULL );