From 6a0c9398deb88ad4787389f50e95a8acad9d7285 Mon Sep 17 00:00:00 2001 From: Yonghye Kwon Date: Mon, 29 Mar 2021 18:06:37 +0900 Subject: [PATCH] efficient darknet parser for commented line efficient darknet parser for commented line --- src/DarknetParser.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/DarknetParser.cpp b/src/DarknetParser.cpp index 69b6b29..b2c28e2 100644 --- a/src/DarknetParser.cpp +++ b/src/DarknetParser.cpp @@ -224,11 +224,10 @@ namespace tk { namespace dnn { darknetFields_t fields; // will be filled with layers fields std::string line; while(std::getline(if_cfg, line)) { - // remove comments + // skip commented line std::size_t found = line.find("#"); - if ( found != std::string::npos ) { - line = line.substr(0, found); - } + if ( found != std::string::npos ) + continue; // skip empty lines if(line.size() == 0)