Hello everyone! Bug 1377351 landed on central recently, and adds move assignment operators and constructors to ns[C]String. These operators attempt to re-use allocations when possible and can reduce the cost of copying strings around.
This could be used in some situations to improve assignment to nsString fields in structs, for example, this call will avoid allocating & using reference counts in more situations than the equivalent code using `const nsAString&`: void SetFoo(nsAString&& aFoo) { mFoo.Assign(Move(aFoo)); } In addition, this can be used to save some work when returning using an outparameter: void GetFoo(nsAString& aOut) { // Somehow get a string value we want to return nsString returnValue = ...; aOut.Assign(Move(returnValue)); } After using one of these move assignment operators, the original string will be truncated. This functionality is also exposed to rust code through the `take_from` method. Consider moving ns[C]String values in the future when assigning to avoid unnecessary work. Nika _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform