[Bf-blender-cvs] [24c3b57ec32] functions: remove unused StringCollection
Jacques Lucke
noreply at git.blender.org
Wed May 22 17:32:26 CEST 2019
Commit: 24c3b57ec3200f748ecf9a869d1da4cb56f1215e
Author: Jacques Lucke
Date: Wed May 22 15:53:15 2019 +0200
Branches: functions
https://developer.blender.org/rB24c3b57ec3200f748ecf9a869d1da4cb56f1215e
remove unused StringCollection
===================================================================
D source/blender/blenlib/BLI_string_collection.hpp
M source/blender/blenlib/CMakeLists.txt
D tests/gtests/blenlib/BLI_string_collection_test.cc
M tests/gtests/blenlib/CMakeLists.txt
===================================================================
diff --git a/source/blender/blenlib/BLI_string_collection.hpp b/source/blender/blenlib/BLI_string_collection.hpp
deleted file mode 100644
index c0180bef214..00000000000
--- a/source/blender/blenlib/BLI_string_collection.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#pragma once
-
-/* Utility classes to store multiple strings in a continuous
- * memory buffer. */
-
-#include "BLI_string_ref.hpp"
-#include "BLI_small_vector.hpp"
-
-namespace BLI {
-
-class StringCollection {
- private:
- const char *m_data;
- SmallVector<StringRefNull> m_strings;
-
- StringCollection(StringCollection &other) = delete;
-
- public:
- StringCollection(const char *data, SmallVector<StringRefNull> strings)
- : m_data(data), m_strings(std::move(strings))
- {
- }
-
- ~StringCollection()
- {
- MEM_freeN((void *)m_data);
- }
-
- StringRefNull get_ref(uint index) const
- {
- return m_strings[index];
- }
-
- uint size() const
- {
- return m_strings.size();
- }
-};
-
-class StringCollectionBuilder {
- private:
- SmallVector<char, 64> m_chars;
- SmallVector<uint> m_offsets;
-
- public:
- StringCollectionBuilder() = default;
-
- /* Returns the index in the final collection */
- uint insert(StringRef ref)
- {
- m_offsets.append(m_chars.size());
- m_chars.extend(ref.data(), ref.size());
- m_chars.append('\0');
- return m_offsets.size() - 1;
- }
-
- StringCollection *build()
- {
- char *data = (char *)MEM_mallocN(m_chars.size(), __func__);
- memcpy(data, m_chars.begin(), m_chars.size());
- SmallVector<StringRefNull> references;
-
- for (uint start_offset : m_offsets) {
- references.append(StringRefNull(data + start_offset));
- }
-
- return new StringCollection(data, references);
- }
-};
-
-} // namespace BLI
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 21e584d2c80..b6b4a3e7647 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -251,7 +251,6 @@ set(SRC
BLI_small_set.hpp
BLI_small_set_vector.hpp
BLI_small_stack.hpp
- BLI_string_collection.hpp
BLI_string_ref.hpp
BLI_timeit.hpp
)
diff --git a/tests/gtests/blenlib/BLI_string_collection_test.cc b/tests/gtests/blenlib/BLI_string_collection_test.cc
deleted file mode 100644
index 8b0745e203a..00000000000
--- a/tests/gtests/blenlib/BLI_string_collection_test.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "testing/testing.h"
-#include "BLI_string_collection.hpp"
-
-using BLI::StringCollection;
-using BLI::StringCollectionBuilder;
-
-TEST(string_collection, Empty)
-{
- StringCollectionBuilder builder;
-
- StringCollection *collection = builder.build();
- EXPECT_EQ(collection->size(), 0);
-}
-
-TEST(string_collection, Single)
-{
- StringCollectionBuilder builder;
- builder.insert("Hello");
-
- StringCollection *collection = builder.build();
- EXPECT_EQ(collection->size(), 1);
- EXPECT_EQ(collection->get_ref(0).size(), 5);
- EXPECT_EQ(collection->get_ref(0).to_std_string(), "Hello");
-}
-
-TEST(string_collection, Multiple)
-{
- StringCollectionBuilder builder;
- EXPECT_EQ(builder.insert("asd"), 0);
- EXPECT_EQ(builder.insert("qwef"), 1);
- EXPECT_EQ(builder.insert("zxcvb"), 2);
-
- StringCollection *collection = builder.build();
- EXPECT_EQ(collection->size(), 3);
- EXPECT_EQ(collection->get_ref(0).to_std_string(), "asd");
- EXPECT_EQ(collection->get_ref(1).to_std_string(), "qwef");
- EXPECT_EQ(collection->get_ref(2).to_std_string(), "zxcvb");
-}
-
-TEST(string_collection, CreatesCopy)
-{
- const char *str = "Test";
-
- StringCollectionBuilder builder;
- builder.insert(str);
-
- StringCollection *collection = builder.build();
- EXPECT_EQ(collection->size(), 1);
- EXPECT_NE(collection->get_ref(0).data(), str);
-}
diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt
index 4fee8372ac7..477a99938ee 100644
--- a/tests/gtests/blenlib/CMakeLists.txt
+++ b/tests/gtests/blenlib/CMakeLists.txt
@@ -70,7 +70,6 @@ BLENDER_TEST(BLI_small_stack "bf_blenlib")
BLENDER_TEST(BLI_small_map "bf_blenlib")
BLENDER_TEST(BLI_stack "bf_blenlib")
BLENDER_TEST(BLI_string "bf_blenlib")
-BLENDER_TEST(BLI_string_collection "bf_blenlib")
BLENDER_TEST(BLI_string_ref "bf_blenlib")
BLENDER_TEST(BLI_string_utf8 "bf_blenlib")
BLENDER_TEST(BLI_task "bf_blenlib;bf_intern_numaapi")
More information about the Bf-blender-cvs
mailing list