@@ -58,12 +58,12 @@ impl DictItem {
5858 }
5959}
6060
61- const MINRATIO : core :: ffi :: c_int = 4 ;
62- const ZDICT_MAX_SAMPLES_SIZE : core :: ffi :: c_uint = ( 2000 ) << 20 ;
61+ const MINRATIO : u32 = 4 ;
62+ const ZDICT_MAX_SAMPLES_SIZE : usize = 2000 << 20 ;
6363#[ expect( deprecated) ]
64- const ZDICT_MIN_SAMPLES_SIZE : core :: ffi :: c_int = ZDICT_CONTENTSIZE_MIN * MINRATIO ;
64+ const ZDICT_MIN_SAMPLES_SIZE : usize = ZDICT_CONTENTSIZE_MIN as usize * MINRATIO as usize ;
6565
66- const NOISELENGTH : core :: ffi :: c_int = 32 ;
66+ const NOISELENGTH : usize = 32 ;
6767static g_selectivity_default: u32 = 9 ;
6868
6969/// Prints the bytes as characters, with non-printable characters replaced by '.', used for debug output
@@ -597,17 +597,17 @@ unsafe fn ZDICT_trainBuffer_legacy(
597597 if suffix0. is_null ( ) || reverseSuffix. is_null ( ) || doneMarks. is_null ( ) || filePos. is_null ( ) {
598598 result = Error :: memory_allocation. to_error_code ( ) ;
599599 } else {
600- if minRatio < MINRATIO as core :: ffi :: c_uint {
601- minRatio = MINRATIO as core :: ffi :: c_uint ;
600+ if minRatio < MINRATIO {
601+ minRatio = MINRATIO ;
602602 }
603603 core:: ptr:: write_bytes ( doneMarks, 0 , bufferSize. wrapping_add ( 16 ) ) ;
604- if bufferSize > ZDICT_MAX_SAMPLES_SIZE as size_t && notificationLevel >= 3 {
604+ if bufferSize > ZDICT_MAX_SAMPLES_SIZE && notificationLevel >= 3 {
605605 eprintln ! (
606606 "sample set too large : reduced to {} MB ..." ,
607607 ( 2000 ) << 20 >> 20 ,
608608 ) ;
609609 }
610- while bufferSize > ZDICT_MAX_SAMPLES_SIZE as size_t {
610+ while bufferSize > ZDICT_MAX_SAMPLES_SIZE {
611611 nbFiles = nbFiles. wrapping_sub ( 1 ) ;
612612 bufferSize = bufferSize. wrapping_sub ( * fileSizes. offset ( nbFiles as isize ) ) ;
613613 }
@@ -1170,7 +1170,7 @@ unsafe fn finalize_dictionary(
11701170 if dictBufferCapacity < dictContentSize {
11711171 return Err ( Error :: dstSize_tooSmall) ;
11721172 }
1173- if dictBufferCapacity < ZDICT_DICTSIZE_MIN as size_t {
1173+ if dictBufferCapacity < ZDICT_DICTSIZE_MIN {
11741174 return Err ( Error :: dstSize_tooSmall) ;
11751175 }
11761176 header[ ..4 ] . copy_from_slice ( & ZSTD_MAGIC_DICTIONARY . to_le_bytes ( ) ) ;
@@ -1307,7 +1307,7 @@ unsafe fn ZDICT_trainFromBuffer_unsafe_legacy(
13071307 params. selectivityLevel
13081308 } ;
13091309 let minRep = if selectivity > 30 {
1310- MINRATIO as core :: ffi :: c_uint
1310+ MINRATIO
13111311 } else {
13121312 nbSamples >> selectivity
13131313 } ;
@@ -1318,11 +1318,11 @@ unsafe fn ZDICT_trainFromBuffer_unsafe_legacy(
13181318 if dictList. is_null ( ) {
13191319 return Error :: memory_allocation. to_error_code ( ) ;
13201320 }
1321- if maxDictSize < ZDICT_DICTSIZE_MIN as size_t {
1321+ if maxDictSize < ZDICT_DICTSIZE_MIN {
13221322 free ( dictList as * mut core:: ffi:: c_void ) ;
13231323 return Error :: dstSize_tooSmall. to_error_code ( ) ;
13241324 }
1325- if samplesBuffSize < ZDICT_MIN_SAMPLES_SIZE as size_t {
1325+ if samplesBuffSize < ZDICT_MIN_SAMPLES_SIZE {
13261326 free ( dictList as * mut core:: ffi:: c_void ) ;
13271327 return Error :: dictionaryCreation_failed. to_error_code ( ) ;
13281328 }
@@ -1372,7 +1372,7 @@ unsafe fn ZDICT_trainFromBuffer_unsafe_legacy(
13721372 }
13731373 let mut dictContentSize_0 = ZDICT_dictSize ( dictList) ;
13741374 #[ expect( deprecated) ]
1375- if dictContentSize_0 < ZDICT_CONTENTSIZE_MIN as core :: ffi :: c_uint {
1375+ if dictContentSize_0 < ZDICT_CONTENTSIZE_MIN {
13761376 free ( dictList as * mut core:: ffi:: c_void ) ;
13771377 return Error :: dictionaryCreation_failed. to_error_code ( ) ;
13781378 }
@@ -1387,7 +1387,7 @@ unsafe fn ZDICT_trainFromBuffer_unsafe_legacy(
13871387 samplesBuffSize >> 20 ,
13881388 ) ;
13891389 }
1390- if minRep > MINRATIO as core :: ffi :: c_uint {
1390+ if minRep > MINRATIO {
13911391 eprintln ! (
13921392 "! consider increasing selectivity to produce larger dictionary (-s{}) " ,
13931393 selectivity. wrapping_add( 1 ) ,
@@ -1398,12 +1398,12 @@ unsafe fn ZDICT_trainFromBuffer_unsafe_legacy(
13981398 }
13991399 }
14001400 if dictContentSize_0 as size_t > targetDictSize * 3
1401- && nbSamples > ( 2 * MINRATIO ) as core :: ffi :: c_uint
1401+ && nbSamples > 2 * MINRATIO
14021402 && selectivity > 1
14031403 && notificationLevel >= 2
14041404 {
14051405 let mut proposedSelectivity = selectivity. wrapping_sub ( 1 ) ;
1406- while nbSamples >> proposedSelectivity <= MINRATIO as core :: ffi :: c_uint {
1406+ while nbSamples >> proposedSelectivity <= MINRATIO {
14071407 proposedSelectivity = proposedSelectivity. wrapping_sub ( 1 ) ;
14081408 }
14091409 eprintln ! (
@@ -1514,10 +1514,10 @@ pub unsafe extern "C" fn ZDICT_trainFromBuffer_legacy(
15141514 } ;
15151515
15161516 let sBuffSize: size_t = samplesSizes. iter ( ) . sum ( ) ;
1517- if sBuffSize < ZDICT_MIN_SAMPLES_SIZE as size_t {
1517+ if sBuffSize < ZDICT_MIN_SAMPLES_SIZE {
15181518 return 0 ;
15191519 }
1520- let mut new_buf = vec ! [ 0u8 ; sBuffSize. wrapping_add( NOISELENGTH as size_t ) ] ;
1520+ let mut new_buf = vec ! [ 0u8 ; sBuffSize. wrapping_add( NOISELENGTH ) ] ;
15211521 core:: ptr:: copy_nonoverlapping ( samplesBuffer. cast :: < u8 > ( ) , new_buf. as_mut_ptr ( ) , sBuffSize) ;
15221522 fill_noise ( & mut new_buf[ sBuffSize..] ) ;
15231523 ZDICT_trainFromBuffer_unsafe_legacy (
0 commit comments