MCPcopy Create free account
hub / github.com/FastLED/FastLED / materialize

Method materialize

src/fl/stl/basic_string.cpp.hpp:163–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163void basic_string::materialize() {
164 if (mStorage.is<ConstLiteral>()) {
165 const char* data = mStorage.get<ConstLiteral>().data;
166 if (!data) {
167 mLength = 0;
168 mStorage.reset();
169 inlineBufferPtr()[0] = '\0';
170 return;
171 }
172 fl::size len = mLength;
173 if (len + 1 <= mInlineCapacity) {
174 fl::memcpy(inlineBufferPtr(), data, len);
175 inlineBufferPtr()[len] = '\0';
176 mStorage.reset();
177 } else {
178 mStorage = NotNullStringHolderPtr(fl::make_shared<StringHolder>(data, len));
179 }
180 } else if (mStorage.is<ConstView>()) {
181 const ConstView& view = mStorage.get<ConstView>();
182 if (!view.data) {
183 mLength = 0;
184 mStorage.reset();
185 inlineBufferPtr()[0] = '\0';
186 return;
187 }
188 fl::size len = view.length;
189 mLength = len;
190 if (len + 1 <= mInlineCapacity) {
191 fl::memcpy(inlineBufferPtr(), view.data, len);
192 inlineBufferPtr()[len] = '\0';
193 mStorage.reset();
194 } else {
195 mStorage = NotNullStringHolderPtr(fl::make_shared<StringHolder>(view.data, len));
196 }
197 }
198}
199
200NotNullStringHolderPtr& basic_string::heapData() {
201 if (!mStorage.is<NotNullStringHolderPtr>()) {

Callers 2

c_strMethod · 0.80
acceptMethod · 0.80

Calls 2

memcpyFunction · 0.50
resetMethod · 0.45

Tested by

no test coverage detected