Skip to content

Commit ed9584f

Browse files
committed
fix issue #505
1 parent 7bb5e38 commit ed9584f

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

include/behaviortree_cpp/utils/simple_string.hpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,23 @@ class SimpleString {
114114
return std::strcmp(data(), other.data()) > 0;
115115
}
116116

117-
bool isSOO() const { return !(_storage.soo.capacity_left & IS_LONG_BIT); }
117+
bool isSOO() const {
118+
return !(_storage.soo.capacity_left & IS_LONG_BIT);
119+
}
118120

119121
private:
120-
constexpr static std::size_t CAPACITY = sizeof(void *) * 2 - 1;
122+
123+
struct String {
124+
char *data;
125+
std::size_t size;
126+
};
127+
128+
constexpr static std::size_t CAPACITY = std::max(size_t(15), sizeof(String) - 1);
121129
constexpr static std::size_t IS_LONG_BIT = 1 << 7;
122-
constexpr static std::size_t LONG_MASK = ~(uint32_t(0));
130+
constexpr static std::size_t LONG_MASK = (~std::size_t(0)) >> 1;
123131

124132
union {
125-
struct String {
126-
char *data;
127-
std::size_t size;
128-
} str;
133+
String str;
129134

130135
struct SOO {
131136
char data[CAPACITY];

0 commit comments

Comments
 (0)