diff --git a/ChangeLog.txt b/ChangeLog.txt index 583129cae0..49ab6444c8 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,11 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-05-29 15:14 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/vm/hashes.c + ! fixed and optimized reordering when KEEPORDER flag is cleared + in recent commit + 2013-05-29 08:53 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/vm/hashes.c % changed sorting algorithm for hash arrays which keeps item order. diff --git a/src/vm/hashes.c b/src/vm/hashes.c index 59b6da3112..2d4b9e459d 100644 --- a/src/vm/hashes.c +++ b/src/vm/hashes.c @@ -210,19 +210,16 @@ static int hb_hashItemCmp( PHB_ITEM pKey1, PHB_ITEM pKey2, int iFlags ) static void hb_hashResort( PHB_BASEHASH pBaseHash ) { HB_SIZE nPos; - + PHB_HASHPAIR pPairs = ( PHB_HASHPAIR ) + hb_xgrab( pBaseHash->nLen * sizeof( HB_HASHPAIR ) ); for( nPos = 0; nPos < pBaseHash->nLen; ++nPos ) { - HB_SIZE nFrom = pBaseHash->pnPos[ nPos ]; - - if( nFrom != nPos ) - { - HB_HASHPAIR pair; - memcpy( &pair, pBaseHash->pPairs + nPos, sizeof( HB_HASHPAIR ) ); - memcpy( pBaseHash->pPairs + nPos, pBaseHash->pPairs + nFrom, sizeof( HB_HASHPAIR ) ); - memcpy( pBaseHash->pPairs + nFrom, &pair, sizeof( HB_HASHPAIR ) ); - } + memcpy( pPairs + nPos, pBaseHash->pPairs + pBaseHash->pnPos[ nPos ], sizeof( HB_HASHPAIR ) ); + pBaseHash->pnPos[ nPos ] = nPos; } + + hb_xfree( pBaseHash->pPairs ); + pBaseHash->pPairs = pPairs; } static void hb_hashSortDo( PHB_BASEHASH pBaseHash )