From 4e36ebf5936b68ba3b0bf59ba6a67a88cb201fad Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 21 Oct 2018 17:17:34 +0200 Subject: 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... --- source/blender/blenkernel/intern/mball.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel/intern/mball.c') 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, '.'); -- cgit v1.2.3