diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-10-21 18:17:34 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-10-21 18:17:34 +0300 |
commit | 4e36ebf5936b68ba3b0bf59ba6a67a88cb201fad (patch) | |
tree | 7696a3e08067b07d3ae92539027e190b0199bb16 /source/blender/blenkernel/intern/mball.c | |
parent | 96fef7db5a21dc63f29a33341e7c9b0cf0b19505 (diff) |
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...
Diffstat (limited to 'source/blender/blenkernel/intern/mball.c')
-rw-r--r-- | source/blender/blenkernel/intern/mball.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 9b2c2e938d4..9abf2693578 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -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, '.'); |