mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Merge "stasis: Reduce calculation of stasis message type hash." into 13
This commit is contained in:
@@ -320,6 +320,14 @@ enum stasis_message_type_result stasis_message_type_create(const char *name,
|
|||||||
*/
|
*/
|
||||||
const char *stasis_message_type_name(const struct stasis_message_type *type);
|
const char *stasis_message_type_name(const struct stasis_message_type *type);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the hash of a given message type
|
||||||
|
* \param type The type to get the hash of.
|
||||||
|
* \return The hash
|
||||||
|
* \since 13.24.0
|
||||||
|
*/
|
||||||
|
unsigned int stasis_message_type_hash(const struct stasis_message_type *type);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Check whether a message type is declined
|
* \brief Check whether a message type is declined
|
||||||
*
|
*
|
||||||
|
@@ -176,7 +176,7 @@ static void cache_entry_dtor(void *obj)
|
|||||||
|
|
||||||
static void cache_entry_compute_hash(struct cache_entry_key *key)
|
static void cache_entry_compute_hash(struct cache_entry_key *key)
|
||||||
{
|
{
|
||||||
key->hash = ast_hashtab_hash_string(stasis_message_type_name(key->type));
|
key->hash = stasis_message_type_hash(key->type);
|
||||||
key->hash += ast_hashtab_hash_string(key->id);
|
key->hash += ast_hashtab_hash_string(key->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,11 +34,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/astobj2.h"
|
#include "asterisk/astobj2.h"
|
||||||
#include "asterisk/stasis.h"
|
#include "asterisk/stasis.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
|
#include "asterisk/hashtab.h"
|
||||||
|
|
||||||
/*! \internal */
|
/*! \internal */
|
||||||
struct stasis_message_type {
|
struct stasis_message_type {
|
||||||
struct stasis_message_vtable *vtable;
|
struct stasis_message_vtable *vtable;
|
||||||
char *name;
|
char *name;
|
||||||
|
unsigned int hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct stasis_message_vtable null_vtable = {};
|
static struct stasis_message_vtable null_vtable = {};
|
||||||
@@ -75,6 +77,7 @@ int stasis_message_type_create(const char *name,
|
|||||||
ao2_cleanup(type);
|
ao2_cleanup(type);
|
||||||
return STASIS_MESSAGE_TYPE_ERROR;
|
return STASIS_MESSAGE_TYPE_ERROR;
|
||||||
}
|
}
|
||||||
|
type->hash = ast_hashtab_hash_string(name);
|
||||||
type->vtable = vtable;
|
type->vtable = vtable;
|
||||||
*result = type;
|
*result = type;
|
||||||
|
|
||||||
@@ -86,6 +89,11 @@ const char *stasis_message_type_name(const struct stasis_message_type *type)
|
|||||||
return type->name;
|
return type->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int stasis_message_type_hash(const struct stasis_message_type *type)
|
||||||
|
{
|
||||||
|
return type->hash;
|
||||||
|
}
|
||||||
|
|
||||||
/*! \internal */
|
/*! \internal */
|
||||||
struct stasis_message {
|
struct stasis_message {
|
||||||
/*! Time the message was created */
|
/*! Time the message was created */
|
||||||
|
Reference in New Issue
Block a user