| 276 | } |
| 277 | |
| 278 | FeatureView |
| 279 | Context::commit(FeatureView const &view) |
| 280 | { |
| 281 | FeatureView zret{view}; |
| 282 | if (view._literal_p) { // already committed. |
| 283 | } else if (view._direct_p) { |
| 284 | auto span{_arena->alloc(view.size())}; |
| 285 | memcpy(span, view); |
| 286 | zret = TextView(span.rebind<char>()); // update full to be the localized copy. |
| 287 | zret._direct_p = false; |
| 288 | zret._literal_p = true; |
| 289 | } else if (auto r{_arena->remnant()}; r.contains(view.data())) { |
| 290 | // it's in transient memory, finalize it. |
| 291 | // Need to commit everything before it as well. |
| 292 | size_t n = (view.data() - r.rebind<char>().data()) + view.size(); |
| 293 | _arena->alloc(n); |
| 294 | _transient = (n >= _transient ? 0 : _transient - n); |
| 295 | zret._literal_p = true; |
| 296 | } else if (_arena->contains(view.data())) { // it's already been committed, mark it so. |
| 297 | zret._literal_p = true; |
| 298 | } |
| 299 | return zret; |
| 300 | } |
| 301 | |
| 302 | Feature & |
| 303 | Context::commit(Feature &feature) |
no test coverage detected