@@ -58,13 +58,7 @@ long long DataCounter::countFromFile(const std::string& filename) {
5858 auto readings = JsonParser::parseJsonLine (line);
5959
6060 // Skip empty JSON arrays/objects if removeEmptyJson is set
61- if (removeEmptyJson) {
62- bool allEmpty = true ;
63- for (const auto & r : readings) {
64- if (!r.empty ()) { allEmpty = false ; break ; }
65- }
66- if (allEmpty) continue ;
67- }
61+ if (removeEmptyJson && areAllReadingsEmpty (readings)) continue ;
6862
6963 for (const auto & reading : readings) {
7064 if (reading.empty ()) continue ;
@@ -116,13 +110,7 @@ long long DataCounter::countFromStdin() {
116110
117111 auto readings = JsonParser::parseJsonLine (line);
118112
119- if (removeEmptyJson) {
120- bool allEmpty = true ;
121- for (const auto & r : readings) {
122- if (!r.empty ()) { allEmpty = false ; break ; }
123- }
124- if (allEmpty) continue ;
125- }
113+ if (removeEmptyJson && areAllReadingsEmpty (readings)) continue ;
126114
127115 for (const auto & reading : readings) {
128116 if (reading.empty ()) continue ;
@@ -176,13 +164,7 @@ void DataCounter::countFromStdinFollow() {
176164 // JSON format
177165 auto readings = JsonParser::parseJsonLine (line);
178166
179- if (removeEmptyJson) {
180- bool allEmpty = true ;
181- for (const auto & r : readings) {
182- if (!r.empty ()) { allEmpty = false ; break ; }
183- }
184- if (allEmpty) continue ;
185- }
167+ if (removeEmptyJson && areAllReadingsEmpty (readings)) continue ;
186168
187169 for (const auto & reading : readings) {
188170 if (reading.empty ()) continue ;
@@ -243,13 +225,7 @@ void DataCounter::countFromFileFollow(const std::string& filename) {
243225 } else {
244226 auto readings = JsonParser::parseJsonLine (line);
245227
246- if (removeEmptyJson) {
247- bool allEmpty = true ;
248- for (const auto & r : readings) {
249- if (!r.empty ()) { allEmpty = false ; break ; }
250- }
251- if (allEmpty) continue ;
252- }
228+ if (removeEmptyJson && areAllReadingsEmpty (readings)) continue ;
253229
254230 for (const auto & reading : readings) {
255231 if (reading.empty ()) continue ;
@@ -287,13 +263,7 @@ void DataCounter::countFromFileFollow(const std::string& filename) {
287263 } else {
288264 auto readings = JsonParser::parseJsonLine (line);
289265
290- if (removeEmptyJson) {
291- bool allEmpty = true ;
292- for (const auto & r : readings) {
293- if (!r.empty ()) { allEmpty = false ; break ; }
294- }
295- if (allEmpty) continue ;
296- }
266+ if (removeEmptyJson && areAllReadingsEmpty (readings)) continue ;
297267
298268 for (const auto & reading : readings) {
299269 if (reading.empty ()) continue ;
@@ -323,15 +293,6 @@ DataCounter::DataCounter(int argc, char* argv[]) : followMode(false) {
323293 }
324294 }
325295
326- // Parse filter options
327- for (int i = 1 ; i < argc; ++i) {
328- std::string arg = argv[i];
329- int result = parseFilterOption (argc, argv, i, arg);
330- if (result >= 0 ) {
331- i = result;
332- }
333- }
334-
335296 // Parse --follow flag
336297 for (int i = 1 ; i < argc; ++i) {
337298 std::string arg = argv[i];
0 commit comments