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
+2
View File
@@ -581,6 +581,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
@@ -942,6 +943,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;
+3 -2
View File
@@ -113,6 +113,7 @@
X( nuser_actuator ) \
X( nuser_sensor ) \
X( nnames ) \
X( nnames_map ) \
X( nM ) \
X( nD ) \
X( nemax ) \
@@ -432,8 +433,8 @@
X( int, name_tupleadr, ntuple, 1 ) \
X( int, name_keyadr, nkey, 1 ) \
X( int, name_pluginadr, nplugin, 1 ) \
X( char, names, nnames, 1 )
X( char, names, nnames, 1 ) \
X( int, names_map, nnames_map, 1 ) \
//-------------------------------- mjData ----------------------------------------------------------