From ced925cfdab23433c7bcb039177b95530635e8ec Mon Sep 17 00:00:00 2001 From: freeHackOfJeff Date: Wed, 23 Jan 2019 10:34:01 +0800 Subject: [PATCH] Localization: refactor GetFileSize method --- .../msf/common/util/system_utility.cc | 21 ++++++++----------- modules/transform/buffer.cc | 4 +--- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/localization/msf/common/util/system_utility.cc b/modules/localization/msf/common/util/system_utility.cc index ba582113d3..bf9f509cb9 100644 --- a/modules/localization/msf/common/util/system_utility.cc +++ b/modules/localization/msf/common/util/system_utility.cc @@ -42,16 +42,12 @@ bool system::CreateDirectory(const std::string& path) { bool system::GetFileSize(const std::string& path, unsigned int* size) { boost::filesystem::path p(path); - if (boost::filesystem::exists(p)) { - if (boost::filesystem::is_regular_file(p)) { - *size = static_cast(boost::filesystem::file_size(p)); - return true; - } else { - return false; - } - } else { - return false; + if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) { + *size = static_cast(boost::filesystem::file_size(p)); + return true; } + + return false; } bool system::CopyFile(const std::string& src, const std::string& dst, @@ -68,11 +64,12 @@ bool system::CopyFile(const std::string& src, const std::string& dst, path_src, path_dst, boost::filesystem::copy_option::overwrite_if_exists, error); } - if (!error) { - return true; - } else { + + if (error) { return false; } + + return true; } void system::GetFilesInFolderRecursive(const std::string& folder, diff --git a/modules/transform/buffer.cc b/modules/transform/buffer.cc index 4f8e6dae61..f6a382f833 100644 --- a/modules/transform/buffer.cc +++ b/modules/transform/buffer.cc @@ -108,9 +108,7 @@ void Buffer::SubscriptionCallbackImpl( static_msgs_.push_back(trans_stamped); } setTransform(trans_stamped, authority, is_static); - } - - catch (tf2::TransformException& ex) { + } catch (tf2::TransformException& ex) { std::string temp = ex.what(); AERROR << "Failure to set recieved transform:" << temp.c_str(); } -- GitLab