I have a function which gets called very often, for this test 30,720,000 times. It has to run in real-time, so performance is very important. Are there possible improvements?// This function looks up in the vertice table wheter a vertice at that position already exists// - If yes, return the vertice index// - If no, create a new vertice and return the created vertice index//// @param cfg: Pointer to a chunkConfig struct// @param x: x position of the vertice// @param y: y position of the verticeinline VERTICE_INDEX GetOrCreateVertice(float x, float y, ChunkGenerator::chunkConfig *cfg) {    int x_pos = int((x*POSARR_ADJ_F) + 0.5f);    int y_pos = int((y*POSARR_ADJ_F) + 0.5f);       int dict_index = x_pos + (y_pos * cfg->subdivisions_adj);    VERTICE_INDEX dict_entry = cfg->vertice_pool.vertice_dict[dict_index];    VERTICE_INDEX current_index = cfg->vertice_pool.current_vertice_index;    if (dict_entry >= 0 && dict_entry < 65535 && current_index > 0)        return dict_entry;    LVecBase3f* offset      = cfg->base_position;    LVecBase2f* dim         = cfg->dimensions;    LVecBase2f* tex_offset  = cfg->texture_offset;    LVecBase2f* tex_scale   = cfg->texture_scale;    int pool_index = ((int)current_index) * 5;    float base_scale = 1.0 / (cfg->subdivisions_f-1.0);    float x_scaled = x * base_scale;    float y_scaled = y * base_scale;    cfg->vertice_pool.vertice_array[pool_index+0] = offset->get_x() + (x_scaled * dim->get_x());    cfg->vertice_pool.vertice_array[pool_index+1] = offset->get_y() + (y_scaled * dim->get_y());    cfg->vertice_pool.vertice_array[pool_index+2] = offset->get_z();    cfg->vertice_pool.vertice_array[pool_index+3] = tex_offset->get_x() + (x_scaled * tex_scale->get_x());    cfg->vertice_pool.vertice_array[pool_index+4] = tex_offset->get_y() + (y_scaled * tex_scale->get_y());    cfg->vertice_pool.vertice_dict[dict_index] = current_index;    cfg->vertice_pool.current_vertice_index++;    return current_index;}LVecBase3f and LVecBase2f are vector-types provided by the graphics-engine I use. VERTICE_INDEX is a unsigned short, POSARR_ADJ and POSARR_ADJ_F is constant 2.This is the chunkConfig struct:struct chunkConfig {    int subdivisions;    int subdivisions_adj;    float subdivisions_f;    LVecBase3f *base_position;    LVecBase2f *dimensions;    LVecBase2f *texture_offset;    LVecBase2f *texture_scale;    verticePool vertice_pool;};struct verticePool {    VERTICE_INDEX current_vertice_index;    VERTICE_INDEX current_primitive_index;    VERTICE_INDEX * vertice_dict;    float *vertice_array;    VERTICE_INDEX *primitive_array;};Performance result measured by very-sleepy: linkVersion based on the suggestions made in the comments: very-sleepy, AMD CodeAnalyst, and the assembler for the slow-line: generated assembler,I also made some arrays global, and renamed vertice to vertex.
Conditionally creating a new vertex
c++;performance;coordinate system