2011-05-11 16:01 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbapi.h
  * harbour/src/vm/hashes.c
    + add new public C function: HB_BOOL hb_hashClear( PHB_ITEM pHash )
    * do not generate RTE when unexisting key is passed to HB_HDEL()
      now code which makes sth like:
         if xKey $ hValue
            hb_hDel( hValue, xKey )
         endif
      can be reduced to:
         hb_hDel( hValue, xKey )

  * harbour/src/vm/hashfunc.c
    + added new PRG function: HB_HCLEAR( <hValue> ) -> <hValue>
This commit is contained in:
Przemyslaw Czerpak
2011-05-11 14:02:04 +00:00
parent fedad7bff3
commit 16037cfc6f
4 changed files with 32 additions and 5 deletions

View File

@@ -16,6 +16,21 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-05-11 16:01 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapi.h
* harbour/src/vm/hashes.c
+ add new public C function: HB_BOOL hb_hashClear( PHB_ITEM pHash )
* do not generate RTE when unexisting key is passed to HB_HDEL()
now code which makes sth like:
if xKey $ hValue
hb_hDel( hValue, xKey )
endif
can be reduced to:
hb_hDel( hValue, xKey )
* harbour/src/vm/hashfunc.c
+ added new PRG function: HB_HCLEAR( <hValue> ) -> <hValue>
2011-05-11 06:55 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbxbp/xbpmenubar.prg
! Changed: XbpMenubar():visible := FALSE to TRUE.

View File

@@ -864,6 +864,7 @@ extern HB_EXPORT HB_BOOL hb_hashDel( PHB_ITEM pHash, PHB_ITEM pKey );
extern HB_EXPORT HB_BOOL hb_hashAdd( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue );
extern HB_EXPORT HB_BOOL hb_hashAddNew( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue );
extern HB_EXPORT HB_BOOL hb_hashRemove( PHB_ITEM pHash, PHB_ITEM pItem );
extern HB_EXPORT HB_BOOL hb_hashClear( PHB_ITEM pHash );
extern HB_EXPORT HB_BOOL hb_hashAllocNewPair( PHB_ITEM pHash, PHB_ITEM * pKeyPtr, PHB_ITEM * pValPtr );
extern HB_EXPORT void hb_hashSort( PHB_ITEM pHash );
extern HB_EXPORT PHB_ITEM hb_hashClone( PHB_ITEM pHash );

View File

@@ -682,7 +682,7 @@ HB_BOOL hb_hashScan( PHB_ITEM pHash, PHB_ITEM pKey, HB_SIZE * pnPos )
return HB_FALSE;
}
static HB_BOOL hb_hashClear( PHB_ITEM pHash )
HB_BOOL hb_hashClear( PHB_ITEM pHash )
{
HB_TRACE(HB_TR_DEBUG, ("hb_hashClear(%p)", pHash));

View File

@@ -169,10 +169,8 @@ HB_FUNC( HB_HDEL )
if( pHash && pKey )
{
if( hb_hashDel( pHash, pKey ) )
hb_itemReturn( pHash );
else
hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 2, pHash, pKey );
hb_hashDel( pHash, pKey );
hb_itemReturn( pHash );
}
else
hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
@@ -289,6 +287,19 @@ HB_FUNC( HB_HVALUES )
hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( HB_HCLEAR )
{
PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
if( pHash )
{
hb_hashClear( pHash );
hb_itemReturn( pHash );
}
else
hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( HB_HFILL )
{
PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );