Implement hash map for mj_name2id using djb2 and linear probing.

PiperOrigin-RevId: 499485127
Change-Id: I5aed6549db18b92d7c8a3b7590e50a00ce13a439
This commit is contained in:
Kyle Bayes
2023-01-04 07:57:11 -08:00
committed by Copybara-Service
parent 5261cceb30
commit f1007df013
11 changed files with 404 additions and 106 deletions
+4
View File
@@ -2,6 +2,10 @@
Changelog
=========
Upcoming version (not yet released)
-----------------------------------
- The function :ref:`mj_name2id` is now implemented using a hash function instead of a linear search for better
performance.
Version 2.3.1 (December 6, 2022)
-----------------------------------
+2
View File
@@ -785,6 +785,7 @@ struct mjModel_ {
int nuser_actuator; // number of mjtNums in actuator_user
int nuser_sensor; // number of mjtNums in sensor_user
int nnames; // number of chars in all names
int nnames_map; // number of slots in the names hash map
// sizes set after mjModel construction (only affect mjData)
int nM; // number of non-zeros in sparse inertia matrix
@@ -1146,6 +1147,7 @@ struct mjModel_ {
int* name_keyadr; // keyframe name pointers (nkey x 1)
int* name_pluginadr; // plugin instance name pointers (nplugin x 1)
char* names; // names of all objects, 0-terminated (nnames x 1)
int* names_map; // internal hash map of names (nnames_map x 1)
};
typedef struct mjModel_ mjModel;
typedef enum mjtPluginCapabilityBit_ {