[Bf-blender-cvs] [7fb768e2c40] functions: cleanup: remove unused class

Jacques Lucke noreply at git.blender.org
Tue Dec 3 15:17:44 CET 2019


Commit: 7fb768e2c40afb343f25f4e7369b518a3b2e6ea0
Author: Jacques Lucke
Date:   Tue Dec 3 15:17:38 2019 +0100
Branches: functions
https://developer.blender.org/rB7fb768e2c40afb343f25f4e7369b518a3b2e6ea0

cleanup: remove unused class

===================================================================

D	source/blender/blenlib/BLI_chained_strings.h
M	source/blender/blenlib/CMakeLists.txt
D	tests/gtests/blenlib/BLI_chained_strings_test.cc
M	tests/gtests/blenlib/CMakeLists.txt

===================================================================

diff --git a/source/blender/blenlib/BLI_chained_strings.h b/source/blender/blenlib/BLI_chained_strings.h
deleted file mode 100644
index 07449399ef5..00000000000
--- a/source/blender/blenlib/BLI_chained_strings.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/** \file
- * \ingroup bli
- *
- * These classes help storing multiple strings more compactly.
- * This should only be used when:
- *   - All strings are freed at the same time.
- *   - The length of individual strings does not change.
- *   - All string lengths are known in the beginning. */
-
-#pragma once
-
-#include "BLI_string_ref.h"
-#include "BLI_vector.h"
-
-namespace BLI {
-
-class ChainedStringRef {
-  uint32_t m_start : 24;
-  uint32_t m_size : 8;
-
- public:
-  ChainedStringRef(uint start, uint size) : m_start(start), m_size(size)
-  {
-    BLI_assert(size < (1 << 8));
-    BLI_assert(start < (1 << 24));
-  }
-
-  uint size() const
-  {
-    return m_size;
-  }
-
-  StringRefNull to_string_ref(const char *ptr) const
-  {
-    return StringRefNull(ptr + m_start, m_size);
-  }
-};
-
-class ChainedStringsBuilder {
- public:
-  ChainedStringRef add(StringRef str)
-  {
-    ChainedStringRef ref(m_chars.size(), str.size());
-    m_chars.extend(str.data(), str.size());
-    m_chars.append(0);
-    return ref;
-  }
-
-  char *build()
-  {
-    char *ptr = (char *)MEM_mallocN(m_chars.size(), __func__);
-    memcpy(ptr, m_chars.begin(), m_chars.size());
-    return ptr;
-  }
-
- private:
-  Vector<char, 64> m_chars;
-};
-
-}  // namespace BLI
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 629058d67ca..fb088d23f48 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -258,7 +258,6 @@ set(SRC
   BLI_dot_export.h
   BLI_dot_export_attribute_enums.h
   intern/dot_export.cc
-  BLI_chained_strings.h
   BLI_lazy_init.h
   BLI_lazy_init_cxx.h
   intern/BLI_lazy_init.cc
diff --git a/tests/gtests/blenlib/BLI_chained_strings_test.cc b/tests/gtests/blenlib/BLI_chained_strings_test.cc
deleted file mode 100644
index 1fdf9959124..00000000000
--- a/tests/gtests/blenlib/BLI_chained_strings_test.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "testing/testing.h"
-#include "BLI_chained_strings.h"
-
-using BLI::ChainedStringRef;
-using BLI::ChainedStringsBuilder;
-
-TEST(chained_strings, BuildEmpty)
-{
-  ChainedStringsBuilder builder;
-  char *str = builder.build();
-  EXPECT_NE(str, nullptr);
-  MEM_freeN(str);
-}
-
-TEST(chained_strings, BuildSingleString)
-{
-  ChainedStringsBuilder builder;
-  auto ref = builder.add("Hello");
-
-  char *str = builder.build();
-
-  EXPECT_EQ(ref.size(), 5);
-  EXPECT_EQ(ref.to_string_ref(str), "Hello");
-
-  MEM_freeN(str);
-}
-
-TEST(chained_strings, BuildMultiple)
-{
-  ChainedStringsBuilder builder;
-  auto ref1 = builder.add("Why");
-  auto ref2 = builder.add("What");
-  auto ref3 = builder.add("Where");
-
-  char *str = builder.build();
-
-  EXPECT_EQ(ref1.size(), 3);
-  EXPECT_EQ(ref2.size(), 4);
-  EXPECT_EQ(ref3.size(), 5);
-
-  EXPECT_EQ(ref1.to_string_ref(str), "Why");
-  EXPECT_EQ(ref2.to_string_ref(str), "What");
-  EXPECT_EQ(ref3.to_string_ref(str), "Where");
-
-  MEM_freeN(str);
-}
diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt
index 9327bb790f7..752a6601e98 100644
--- a/tests/gtests/blenlib/CMakeLists.txt
+++ b/tests/gtests/blenlib/CMakeLists.txt
@@ -43,7 +43,6 @@ BLENDER_TEST(BLI_array_ref "bf_blenlib")
 BLENDER_TEST(BLI_array_store "bf_blenlib")
 BLENDER_TEST(BLI_array_utils "bf_blenlib")
 BLENDER_TEST(BLI_bit_array_ref "bf_blenlib")
-BLENDER_TEST(BLI_chained_strings "bf_blenlib")
 BLENDER_TEST(BLI_chunked_range "bf_blenlib")
 BLENDER_TEST(BLI_delaunay_2d "bf_blenlib")
 BLENDER_TEST(BLI_edgehash "bf_blenlib")



More information about the Bf-blender-cvs mailing list