Add new string type rdcinflexiblestr specifically for structured data

* This is a string type which heavily optimises for immutability and minimal
  storage. It only contains one pointer to the string data and always
  reallocates on modify. For compile-time literals it doesn't modify or
  allocate.
* On x64 we use the top bit in a tagged pointer to store a flag of whether it's
  heap or literal, on other platforms it uses a separate field (meaning another
  pointer sized value effectively, including padding).
* This is best for structured data which tends to use a lot of immutable strings
  for type/name information, and only a few for actual string data (which are
  only allocated once and aren't modified after that). Similarly we rarely want
  to know only the size of any of these strings, we want the whole string so not
  explicitly storing the size is not a big deal.
* Overall this reduces SDObject from 128 bytes to 80 bytes.
This commit is contained in:
baldurk
2020-10-26 16:20:20 +00:00
parent c58f3edafa
commit 935cb113ed
18 changed files with 396 additions and 71 deletions
+1 -1
View File
@@ -603,7 +603,7 @@ QWidget *SettingDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
val->ReserveChildren(items.size());
for(int i = 0; i < items.size(); i++)
val->AddAndOwnChild(makeSDString("$el", items[i]));
val->AddAndOwnChild(makeSDString("$el"_lit, items[i]));
}
// we've handled the edit synchronously, don't create an edit widget