diff --git a/ChangeLog.txt b/ChangeLog.txt index 8915d3569b..b6fa54a97d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,16 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2015-03-18 23:16 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * include/hbrddcdx.h + * src/rdd/dbfcdx/dbfcdx1.c + % small speed improvement during indexing + * casting + + * src/rdd/dbfnsx/dbfnsx1.c + * src/rdd/dbfntx/dbfntx1.c + * casting + 2015-03-18 13:25 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/teditor.prg ! resize missing text on line wrapping (issue #92) diff --git a/include/hbrddcdx.h b/include/hbrddcdx.h index 1cd4e06fe8..5cf53a83e3 100644 --- a/include/hbrddcdx.h +++ b/include/hbrddcdx.h @@ -425,6 +425,7 @@ typedef struct HB_ULONG ulPgKeys; /* maximum number of key in page memory buffer */ HB_ULONG ulMaxKey; /* maximum number of keys in single page */ HB_BYTE * pKeyPool; /* memory buffer for current page then for pages */ + HB_BYTE * pStartKey; /* begining of key pool after sorting */ LPCDXSWAPPAGE pSwapPage; /* list of pages */ LPCDXPAGE NodeList[ CDX_STACKSIZE ]; /* Stack of pages */ HB_ULONG ulFirst; diff --git a/src/rdd/dbfcdx/dbfcdx1.c b/src/rdd/dbfcdx/dbfcdx1.c index 2f2e9d8fd7..863a730191 100644 --- a/src/rdd/dbfcdx/dbfcdx1.c +++ b/src/rdd/dbfcdx/dbfcdx1.c @@ -8996,15 +8996,15 @@ static HB_BOOL hb_cdxQSort( LPCDXSORTINFO pSort, HB_BYTE * pSrc, HB_BYTE * pBuf, static void hb_cdxSortSortPage( LPCDXSORTINFO pSort ) { - HB_SIZE nSize = pSort->ulKeys * ( pSort->keyLen + 4 ); + HB_SIZE nSize = ( HB_SIZE ) pSort->ulKeys * ( pSort->keyLen + 4 ); #ifdef HB_CDX_DBGTIME cdxTimeIdxBld -= hb_cdxGetTime(); #endif if( ! hb_cdxQSort( pSort, pSort->pKeyPool, &pSort->pKeyPool[ nSize ], pSort->ulKeys ) ) - { - memcpy( pSort->pKeyPool, &pSort->pKeyPool[ nSize ], nSize ); - } + pSort->pStartKey = &pSort->pKeyPool[ nSize ]; + else + pSort->pStartKey = pSort->pKeyPool; #ifdef HB_CDX_DBGTIME cdxTimeIdxBld += hb_cdxGetTime(); #endif @@ -9116,7 +9116,7 @@ static void hb_cdxSortAddNodeKey( LPCDXSORTINFO pSort, int iLevel, HB_BYTE * pKe static void hb_cdxSortWritePage( LPCDXSORTINFO pSort ) { - HB_SIZE nSize = pSort->ulKeys * ( pSort->keyLen + 4 ); + HB_SIZE nSize = ( HB_SIZE ) pSort->ulKeys * ( pSort->keyLen + 4 ); hb_cdxSortSortPage( pSort ); @@ -9130,7 +9130,7 @@ static void hb_cdxSortWritePage( LPCDXSORTINFO pSort ) } pSort->pSwapPage[ pSort->ulCurPage ].ulKeys = pSort->ulKeys; pSort->pSwapPage[ pSort->ulCurPage ].nOffset = hb_fileSize( pSort->pTempFile ); - if( hb_fileWriteAt( pSort->pTempFile, pSort->pKeyPool, + if( hb_fileWriteAt( pSort->pTempFile, pSort->pStartKey, nSize, pSort->pSwapPage[ pSort->ulCurPage ].nOffset ) != nSize ) hb_errInternal( 9302, "hb_cdxSortWritePage: Write error in temporary file.", NULL, NULL ); pSort->ulKeys = 0; @@ -9145,7 +9145,7 @@ static void hb_cdxSortGetPageKey( LPCDXSORTINFO pSort, HB_ULONG ulPage, if( pSort->pSwapPage[ ulPage ].ulKeyBuf == 0 ) { HB_ULONG ulKeys = HB_MIN( pSort->ulPgKeys, pSort->pSwapPage[ ulPage ].ulKeys ); - HB_SIZE nSize = ulKeys * ( iLen + 4 ); + HB_SIZE nSize = ( HB_SIZE ) ulKeys * ( iLen + 4 ); if( hb_fileReadAt( pSort->pTempFile, pSort->pSwapPage[ ulPage ].pKeyPool, nSize, pSort->pSwapPage[ ulPage ].nOffset ) != nSize ) @@ -9465,7 +9465,7 @@ static void hb_cdxSortOut( LPCDXSORTINFO pSort ) pSort->pSwapPage[ 0 ].ulKeys = pSort->ulKeys; pSort->pSwapPage[ 0 ].ulKeyBuf = pSort->ulKeys; pSort->pSwapPage[ 0 ].ulCurKey = 0; - pSort->pSwapPage[ 0 ].pKeyPool = pSort->pKeyPool; + pSort->pSwapPage[ 0 ].pKeyPool = pSort->pStartKey; } #ifdef HB_CDX_NEW_SORT @@ -9669,7 +9669,7 @@ static void hb_cdxTagDoIndex( LPCDXTAG pTag, HB_BOOL fReindex ) iRec = ulRecCount - ulRecNo + 1; if( ulNextCount > 0 && ulNextCount < ( HB_ULONG ) iRec ) iRec = ( int ) ulNextCount; - nSize = iRec * pArea->dbfarea.uiRecordLen; + nSize = ( HB_SIZE ) iRec * pArea->dbfarea.uiRecordLen; if( hb_fileReadAt( pArea->dbfarea.pDataFile, pSort->pRecBuff, nSize, ( HB_FOFFSET ) pArea->dbfarea.uiHeaderLen + ( HB_FOFFSET ) ( ulRecNo - 1 ) * diff --git a/src/rdd/dbfnsx/dbfnsx1.c b/src/rdd/dbfnsx/dbfnsx1.c index 42a53c65b5..b0d2b2a0bb 100644 --- a/src/rdd/dbfnsx/dbfnsx1.c +++ b/src/rdd/dbfnsx/dbfnsx1.c @@ -5087,28 +5087,24 @@ static HB_BOOL hb_nsxQSort( LPNSXSORTINFO pSort, HB_UCHAR * pSrc, HB_UCHAR * pBu static void hb_nsxSortSortPage( LPNSXSORTINFO pSort ) { - HB_ULONG ulSize = pSort->ulKeys * ( pSort->keyLen + 4 ); + HB_SIZE nSize = ( HB_SIZE ) pSort->ulKeys * ( pSort->keyLen + 4 ); - if( ! hb_nsxQSort( pSort, pSort->pKeyPool, &pSort->pKeyPool[ ulSize ], pSort->ulKeys ) ) - { - pSort->pStartKey = &pSort->pKeyPool[ ulSize ]; - } + if( ! hb_nsxQSort( pSort, pSort->pKeyPool, &pSort->pKeyPool[ nSize ], pSort->ulKeys ) ) + pSort->pStartKey = &pSort->pKeyPool[ nSize ]; else - { pSort->pStartKey = pSort->pKeyPool; - } } static void hb_nsxSortBufferFlush( LPNSXSORTINFO pSort ) { - HB_ULONG ulSize; + HB_SIZE nSize; if( pSort->ulPagesIO ) { LPNSXINDEX pIndex = pSort->pTag->pIndex; - ulSize = pSort->ulPagesIO * NSX_PAGELEN; - if( hb_fileWriteAt( pIndex->pFile, pSort->pBuffIO, ulSize, - hb_nsxFileOffset( pIndex, pSort->ulFirstIO ) ) != ulSize ) + nSize = ( HB_SIZE ) pSort->ulPagesIO * NSX_PAGELEN; + if( hb_fileWriteAt( pIndex->pFile, pSort->pBuffIO, nSize, + hb_nsxFileOffset( pIndex, pSort->ulFirstIO ) ) != nSize ) { hb_nsxErrorRT( pIndex->pArea, EG_WRITE, EDBF_WRITE, pIndex->IndexName, hb_fsError(), 0, NULL ); @@ -5236,7 +5232,7 @@ static void hb_nsxSortAddNodeKey( LPNSXSORTINFO pSort, HB_UCHAR * pKeyVal, HB_UL static void hb_nsxSortWritePage( LPNSXSORTINFO pSort ) { - HB_SIZE nSize = pSort->ulKeys * ( pSort->keyLen + 4 ); + HB_SIZE nSize = ( HB_SIZE ) pSort->ulKeys * ( pSort->keyLen + 4 ); hb_nsxSortSortPage( pSort ); @@ -5274,7 +5270,7 @@ static void hb_nsxSortGetPageKey( LPNSXSORTINFO pSort, HB_ULONG ulPage, if( pSort->pSwapPage[ ulPage ].ulKeyBuf == 0 ) { HB_ULONG ulKeys = HB_MIN( pSort->ulPgKeys, pSort->pSwapPage[ ulPage ].ulKeys ); - HB_SIZE nSize = ulKeys * ( iLen + 4 ); + HB_SIZE nSize = ( HB_SIZE ) ulKeys * ( iLen + 4 ); if( pSort->pTempFile != NULL && hb_fileReadAt( pSort->pTempFile, pSort->pSwapPage[ ulPage ].pKeyPool, @@ -5931,7 +5927,7 @@ static HB_ERRCODE hb_nsxTagCreate( LPTAGINFO pTag, HB_BOOL fReindex ) iRec = ulRecCount - ulRecNo + 1; if( ulNextCount > 0 && ulNextCount < ( HB_ULONG ) iRec ) iRec = ( int ) ulNextCount; - nSize = iRec * pArea->dbfarea.uiRecordLen; + nSize = ( HB_SIZE ) iRec * pArea->dbfarea.uiRecordLen; if( hb_fileReadAt( pArea->dbfarea.pDataFile, pSort->pBuffIO, nSize, ( HB_FOFFSET ) pArea->dbfarea.uiHeaderLen + ( HB_FOFFSET ) ( ulRecNo - 1 ) * diff --git a/src/rdd/dbfntx/dbfntx1.c b/src/rdd/dbfntx/dbfntx1.c index b2999fec5d..a0dac8a068 100644 --- a/src/rdd/dbfntx/dbfntx1.c +++ b/src/rdd/dbfntx/dbfntx1.c @@ -4707,16 +4707,12 @@ static HB_BOOL hb_ntxQSort( LPNTXSORTINFO pSort, HB_BYTE * pSrc, HB_BYTE * pBuf, static void hb_ntxSortSortPage( LPNTXSORTINFO pSort ) { - HB_ULONG ulSize = pSort->ulKeys * ( pSort->keyLen + 4 ); + HB_SIZE nSize = ( HB_SIZE ) pSort->ulKeys * ( pSort->keyLen + 4 ); - if( ! hb_ntxQSort( pSort, pSort->pKeyPool, &pSort->pKeyPool[ ulSize ], pSort->ulKeys ) ) - { - pSort->pStartKey = &pSort->pKeyPool[ ulSize ]; - } + if( ! hb_ntxQSort( pSort, pSort->pKeyPool, &pSort->pKeyPool[ nSize ], pSort->ulKeys ) ) + pSort->pStartKey = &pSort->pKeyPool[ nSize ]; else - { pSort->pStartKey = pSort->pKeyPool; - } } static void hb_ntxSortBufferFlush( LPNTXSORTINFO pSort ) @@ -4726,7 +4722,7 @@ static void hb_ntxSortBufferFlush( LPNTXSORTINFO pSort ) if( pSort->ulPagesIO ) { LPNTXINDEX pIndex = pSort->pTag->pIndex; - nSize = pSort->ulPagesIO * NTXBLOCKSIZE; + nSize = ( HB_SIZE ) pSort->ulPagesIO * NTXBLOCKSIZE; if( hb_fileWriteAt( pIndex->DiskFile, pSort->pBuffIO, nSize, hb_ntxFileOffset( pIndex, pSort->ulFirstIO ) ) != nSize ) { @@ -4804,7 +4800,7 @@ static void hb_ntxSortAddNodeKey( LPNTXSORTINFO pSort, HB_BYTE * pKeyVal, HB_ULO static void hb_ntxSortWritePage( LPNTXSORTINFO pSort ) { - HB_SIZE nSize = pSort->ulKeys * ( pSort->keyLen + 4 ); + HB_SIZE nSize = ( HB_SIZE ) pSort->ulKeys * ( pSort->keyLen + 4 ); hb_ntxSortSortPage( pSort ); @@ -4842,7 +4838,7 @@ static void hb_ntxSortGetPageKey( LPNTXSORTINFO pSort, HB_ULONG ulPage, if( pSort->pSwapPage[ ulPage ].ulKeyBuf == 0 ) { HB_ULONG ulKeys = HB_MIN( pSort->ulPgKeys, pSort->pSwapPage[ ulPage ].ulKeys ); - HB_SIZE nSize = ulKeys * ( iLen + 4 ); + HB_SIZE nSize = ( HB_SIZE ) ulKeys * ( iLen + 4 ); if( pSort->pTempFile != NULL && hb_fileReadAt( pSort->pTempFile, pSort->pSwapPage[ ulPage ].pKeyPool, @@ -5436,7 +5432,7 @@ static HB_ERRCODE hb_ntxTagCreate( LPTAGINFO pTag, HB_BOOL fReindex ) iRec = ulRecCount - ulRecNo + 1; if( ulNextCount > 0 && ulNextCount < ( HB_ULONG ) iRec ) iRec = ( int ) ulNextCount; - nSize = iRec * pArea->dbfarea.uiRecordLen; + nSize = ( HB_SIZE ) iRec * pArea->dbfarea.uiRecordLen; if( hb_fileReadAt( pArea->dbfarea.pDataFile, pSort->pBuffIO, nSize, ( HB_FOFFSET ) pArea->dbfarea.uiHeaderLen + ( HB_FOFFSET ) ( ulRecNo - 1 ) *