Optimize meta-ball basis check.

`BKE_mball_is_basis_for()` was processing whole name, when we can
actually rule out most of cases by just checking third char of the ID
names first, which is much, much cheaper.

Even though MBalls are not much used nowadays, that's a nice
optimization when this is called over a whole Main database full of
meta-balls objects...
This commit is contained in:
2018-10-21 17:17:34 +02:00
parent 96fef7db5a
commit 4e36ebf593

View File

@@ -312,6 +312,11 @@ bool BKE_mball_is_basis_for(Object *ob1, Object *ob2)
int basis1nr, basis2nr;
char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME];
if (ob1->id.name[2] != ob2->id.name[2]) {
/* Quick return in case first char of both ID's names is not the same... */
return false;
}
BLI_split_name_num(basis1name, &basis1nr, ob1->id.name + 2, '.');
BLI_split_name_num(basis2name, &basis2nr, ob2->id.name + 2, '.');