]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add Args::empty method
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 1 May 2020 17:51:49 +0000 (19:51 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 4 May 2020 20:40:55 +0000 (22:40 +0200)
src/Args.hpp
src/ccache.cpp
unittest/test_Args.cpp

index ab1a91f384d6710154a1803a28e8687d135255fe..cd2a2849f820cce833adde393bf1804672f8ed9a 100644 (file)
@@ -46,6 +46,7 @@ public:
   bool operator==(const Args& other) const;
   bool operator!=(const Args& other) const;
 
+  bool empty() const;
   size_t size() const;
   const std::string& operator[](size_t i) const;
   std::string& operator[](size_t i);
@@ -120,6 +121,12 @@ Args::operator!=(const Args& other) const
   return m_args != other.m_args;
 }
 
+inline bool
+Args::empty() const
+{
+  return m_args.empty();
+}
+
 inline size_t
 Args::size() const
 {
index 2d6d4792f4aa5e89cd92fce4a0640f7c56c3750f..a4b8585e569620dfce48526239131de1a953413b 100644 (file)
@@ -3457,7 +3457,7 @@ cache_compilation(int argc, const char* const* argv)
     }
     // Else: Fall back to running the real compiler.
 
-    assert(ctx.orig_args.size() > 0);
+    assert(!ctx.orig_args.empty());
 
     args_strip(ctx.orig_args, "--ccache-");
     add_prefix(ctx, ctx.orig_args, ctx.config.prefix_command());
index e61b0bdec99af6417de1d90f696b30f151498fb3..49f2a28b60406966c623f5e37345d096c5e7a9d6 100644 (file)
@@ -167,6 +167,14 @@ TEST_CASE("Args equality operators")
   CHECK(args3 != args1);
 }
 
+TEST_CASE("Args::empty")
+{
+  Args args;
+  CHECK(args.empty());
+  args.push_back("1");
+  CHECK(!args.empty());
+}
+
 TEST_CASE("Args::size")
 {
   Args args;