]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Use constructor member initializer lists
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 19 Apr 2023 20:00:38 +0000 (22:00 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 19 Apr 2023 20:03:01 +0000 (22:03 +0200)
As suggested by clang-tidy
(cppcoreguidelines-prefer-member-initializer).

src/File.hpp
src/Stat.cpp

index eea2c09c62462d05b87ba2a80b2df3092dd8caae..5ace57041273bebb9c6b10f4407887c7d1edf791 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2021 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2023 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -46,10 +46,8 @@ private:
   bool m_owned = false;
 };
 
-inline File::File(FILE* const file)
+inline File::File(FILE* const file) : m_file(file), m_owned(false)
 {
-  m_file = file;
-  m_owned = false;
 }
 
 inline File::File(const std::string& path, const char* mode)
index 87b20203c07ce732f569427d0d26b7d56b967def..15293e12b1e6f5a9b4a4f06a80af423579545a7e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2022 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2023 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -206,8 +206,8 @@ win32_lstat(const char* path, Stat::stat_t* st)
 Stat::Stat(StatFunction stat_function,
            const std::string& path,
            Stat::OnError on_error)
+  : m_path(path)
 {
-  m_path = path;
   int result = stat_function(path.c_str(), &m_stat);
   if (result == 0) {
     m_errno = 0;