BLI: Use simpler sliced generic virtual arrays when possible
This is just a theoretical improvement currently, I won't try to justify it with some microbenchmark, but it should be better to use the specialized single and span virtual arrays when slicing a `GVArray`, since any use of `GVArrayImpl_For_SlicedGVArray` has extra overhead. Differential Revision: https://developer.blender.org/D15361
This commit is contained in:
parent
242bfd28ce
commit
6e879c3998
Notes:
blender-bot
2023-02-14 05:51:15 +01:00
Referenced by issue #99459, GPencil: Fill tool on the surface will not be fill in correct place.
|
@ -688,6 +688,15 @@ GVArray GVArray::ForEmpty(const CPPType &type)
|
|||
|
||||
GVArray GVArray::slice(IndexRange slice) const
|
||||
{
|
||||
const CommonVArrayInfo info = this->common_info();
|
||||
if (info.type == CommonVArrayInfo::Type::Single) {
|
||||
return GVArray::ForSingle(this->type(), slice.size(), info.data);
|
||||
}
|
||||
/* Need to check for ownership, because otherwise the referenced data can be destructed when
|
||||
* #this is destructed. */
|
||||
if (info.type == CommonVArrayInfo::Type::Span && !info.may_have_ownership) {
|
||||
return GVArray::ForSpan(GSpan(this->type(), info.data, this->size()).slice(slice));
|
||||
}
|
||||
return GVArray::For<GVArrayImpl_For_SlicedGVArray>(*this, slice);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue