Skip to content

Commit a72267c

Browse files
michielp1807folkertdev
authored andcommitted
Clean up consecutive notificationLevel checks
1 parent 98e3b66 commit a72267c

File tree

1 file changed

+37
-64
lines changed

1 file changed

+37
-64
lines changed

lib/dictBuilder/zdict.rs

Lines changed: 37 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,12 @@ unsafe fn ZDICT_analyzePos(
228228
let mut refinedEnd = end;
229229
if notificationLevel >= 4 {
230230
eprintln!();
231-
}
232-
if notificationLevel >= 4 {
233231
eprint!(
234232
"found {:>3} matches of length >= {} at pos {:>7} ",
235233
end.wrapping_sub(start),
236234
MINMATCHLENGTH,
237235
pos as core::ffi::c_uint,
238236
);
239-
}
240-
if notificationLevel >= 4 {
241237
eprintln!();
242238
}
243239
mml = MINMATCHLENGTH as u32;
@@ -1190,8 +1186,6 @@ unsafe fn finalize_dictionary(
11901186
hSize = 8;
11911187
if notificationLevel >= 2 {
11921188
eprintln!("\r{:70 }\r", "");
1193-
}
1194-
if notificationLevel >= 2 {
11951189
eprintln!("statistics ...");
11961190
}
11971191
let eSize = ZDICT_analyzeEntropy(
@@ -1250,8 +1244,6 @@ unsafe fn ZDICT_addEntropyTablesFromBuffer_advanced(
12501244
let mut hSize = 8;
12511245
if notificationLevel >= 2 {
12521246
eprintln!("\r{:70 }\r", "");
1253-
}
1254-
if notificationLevel >= 2 {
12551247
eprintln!("statistics ...");
12561248
}
12571249
let res = ZDICT_analyzeEntropy(
@@ -1349,16 +1341,12 @@ unsafe fn ZDICT_trainFromBuffer_unsafe_legacy(
13491341
let nb = Ord::min(25, (*dictList).pos);
13501342
let dictContentSize = ZDICT_dictSize(dictList);
13511343
let mut u: core::ffi::c_uint = 0;
1352-
if notificationLevel >= 3 {
1353-
eprintln!(
1354-
"\n {} segments found, of total size {} ",
1355-
((*dictList).pos).wrapping_sub(1),
1356-
dictContentSize,
1357-
);
1358-
}
1359-
if notificationLevel >= 3 {
1360-
eprintln!("list {} best segments ", nb.wrapping_sub(1));
1361-
}
1344+
eprintln!(
1345+
"\n {} segments found, of total size {} ",
1346+
((*dictList).pos).wrapping_sub(1),
1347+
dictContentSize,
1348+
);
1349+
eprintln!("list {} best segments ", nb.wrapping_sub(1));
13621350
u = 1;
13631351
while u < nb {
13641352
let pos = (*dictList.offset(u as isize)).pos;
@@ -1370,19 +1358,15 @@ unsafe fn ZDICT_trainFromBuffer_unsafe_legacy(
13701358
free(dictList as *mut core::ffi::c_void);
13711359
return Error::GENERIC.to_error_code();
13721360
}
1373-
if notificationLevel >= 3 {
1374-
eprint!(
1375-
"{:3}:{:3} bytes at pos {:8}, savings {:7} bytes |",
1376-
u,
1377-
length,
1378-
pos,
1379-
(*dictList.offset(u as isize)).savings,
1380-
);
1381-
}
1361+
eprint!(
1362+
"{:3}:{:3} bytes at pos {:8}, savings {:7} bytes |",
1363+
u,
1364+
length,
1365+
pos,
1366+
(*dictList.offset(u as isize)).savings,
1367+
);
13821368
ZDICT_printHex(&samples[..printedLength as usize]);
1383-
if notificationLevel >= 3 {
1384-
eprintln!("|");
1385-
}
1369+
eprintln!("|");
13861370
u = u.wrapping_add(1);
13871371
}
13881372
}
@@ -1392,56 +1376,45 @@ unsafe fn ZDICT_trainFromBuffer_unsafe_legacy(
13921376
free(dictList as *mut core::ffi::c_void);
13931377
return Error::dictionaryCreation_failed.to_error_code();
13941378
}
1395-
if (dictContentSize_0 as size_t) < targetDictSize / 4 {
1396-
if notificationLevel >= 2 {
1397-
eprintln!(
1398-
"! warning : selected content significantly smaller than requested ({} < {}) ",
1399-
dictContentSize_0, maxDictSize,
1400-
);
1401-
}
1402-
if samplesBuffSize < 10 * targetDictSize && notificationLevel >= 2 {
1379+
if (dictContentSize_0 as size_t) < targetDictSize / 4 && notificationLevel >= 2 {
1380+
eprintln!(
1381+
"! warning : selected content significantly smaller than requested ({} < {}) ",
1382+
dictContentSize_0, maxDictSize,
1383+
);
1384+
if samplesBuffSize < 10 * targetDictSize {
14031385
eprintln!(
14041386
"! consider increasing the number of samples (total size : {} MB)",
14051387
samplesBuffSize >> 20,
14061388
);
14071389
}
14081390
if minRep > MINRATIO as core::ffi::c_uint {
1409-
if notificationLevel >= 2 {
1410-
eprintln!(
1411-
"! consider increasing selectivity to produce larger dictionary (-s{}) ",
1412-
selectivity.wrapping_add(1),
1413-
);
1414-
}
1415-
if notificationLevel >= 2 {
1416-
eprintln!(
1417-
"! note : larger dictionaries are not necessarily better, test its efficiency on samples "
1418-
);
1419-
}
1391+
eprintln!(
1392+
"! consider increasing selectivity to produce larger dictionary (-s{}) ",
1393+
selectivity.wrapping_add(1),
1394+
);
1395+
eprintln!(
1396+
"! note : larger dictionaries are not necessarily better, test its efficiency on samples "
1397+
);
14201398
}
14211399
}
14221400
if dictContentSize_0 as size_t > targetDictSize * 3
14231401
&& nbSamples > (2 * MINRATIO) as core::ffi::c_uint
14241402
&& selectivity > 1
1403+
&& notificationLevel >= 2
14251404
{
14261405
let mut proposedSelectivity = selectivity.wrapping_sub(1);
14271406
while nbSamples >> proposedSelectivity <= MINRATIO as core::ffi::c_uint {
14281407
proposedSelectivity = proposedSelectivity.wrapping_sub(1);
14291408
}
1430-
if notificationLevel >= 2 {
1431-
eprintln!(
1432-
"! note : calculated dictionary significantly larger than requested ({} > {}) ",
1433-
dictContentSize_0, maxDictSize,
1434-
);
1435-
}
1436-
if notificationLevel >= 2 {
1437-
eprintln!(
1438-
"! consider increasing dictionary size, or produce denser dictionary (-s{}) ",
1439-
proposedSelectivity,
1440-
);
1441-
}
1442-
if notificationLevel >= 2 {
1443-
eprintln!("! always test dictionary efficiency on real samples");
1444-
}
1409+
eprintln!(
1410+
"! note : calculated dictionary significantly larger than requested ({} > {}) ",
1411+
dictContentSize_0, maxDictSize,
1412+
);
1413+
eprintln!(
1414+
"! consider increasing dictionary size, or produce denser dictionary (-s{}) ",
1415+
proposedSelectivity,
1416+
);
1417+
eprintln!("! always test dictionary efficiency on real samples");
14451418
}
14461419
let max = (*dictList).pos;
14471420
let mut currentSize = 0u32;

0 commit comments

Comments
 (0)