| 254 | using NamesVector = StaticVector<StringBox, ReferenceInfo::kNamesSize>; |
| 255 | |
| 256 | static bool assignComponent(ComponentsVector& components, |
| 257 | NamesVector& names, |
| 258 | ReferenceInfo::Component::Type type, |
| 259 | size_t index, |
| 260 | const StringBox* name, |
| 261 | bool isFunction) { |
| 262 | if (components.size() >= ComponentsVector::capacity()) { |
| 263 | return false; |
| 264 | } |
| 265 | |
| 266 | auto& outComponent = components.emplace_back(); |
| 267 | |
| 268 | if (name != nullptr && !name->isEmpty()) { |
| 269 | if (names.size() < NamesVector::capacity()) { |
| 270 | outComponent.hasAssignedName = true; |
| 271 | outComponent.index = static_cast<uint8_t>(names.size()); |
| 272 | names.emplace_back(*name); |
| 273 | } |
| 274 | } else { |
| 275 | outComponent.index = static_cast<uint8_t>(index); |
| 276 | } |
| 277 | outComponent.type = type; |
| 278 | outComponent.isFunction = isFunction; |
| 279 | |
| 280 | return true; |
| 281 | } |
| 282 | |
| 283 | static void assignReferenceInfo(ComponentsVector& components, |
| 284 | NamesVector& names, |
no test coverage detected