Commit: 14d1ad8dd8380dab783e6517c437a90cbf73c398
Author: Bastien Montagne
Date: Thu Jun 9 14:58:35 2022 +0200
Branches: master
https://developer.blender.org/rB14d1ad8dd8380dab783e6517c437a90cbf73c398
FCurve: optimize search from an RNA path + index.
By checking the index value first instead of a full fledge string
comparision in `BKE_fcurve_find`, we can make that code significatly
faster (from about 10% in a Heist production file to over 45% in a
heavily animated test file).
While this code was already very fast (a few microseconds per call
typically), it gets called a lot from the UI (several hundreds of time
per refresh), among other things.
NOTE: the `UNLIKELY` hint is responsible for 25% to 30% of the
speed improvement.
===================================================================
M source/blender/blenkernel/intern/fcurve.c
===================================================================
diff --git a/source/blender/blenkernel/intern/fcurve.c
b/source/blender/blenkernel/intern/fcurve.c
index 48ba6a851d2..0203620df84 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -256,12 +256,11 @@ FCurve *BKE_fcurve_find(ListBase *list, const char
rna_path[], const int array_i
/* Check paths of curves, then array indices... */
for (fcu = list->first; fcu; fcu = fcu->next) {
+ /* Check indices first, much cheaper than a string comparison. */
/* Simple string-compare (this assumes that they have the same root...) */
- if (fcu->rna_path && STREQ(fcu->rna_path, rna_path)) {
- /* Now check indices. */
- if (fcu->array_index == array_index) {
- return fcu;
- }
+ if (UNLIKELY(fcu->array_index == array_index && fcu->rna_path &&
+ fcu->rna_path[0] == rna_path[0] && STREQ(fcu->rna_path,
rna_path))) {
+ return fcu;
}
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs