mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Speed and code space optimziation:
- Cache variables.lc_messages->errmsgs->errmsgs in variables.errmsgs This gives us 15 byte less code space and 2 memory references for any access to language dependent message, of which there are 500 in the server..
This commit is contained in:
@@ -4376,9 +4376,11 @@ static int init_common_variables()
|
||||
sql_print_error("Unknown locale: '%s'", lc_messages);
|
||||
return 1;
|
||||
}
|
||||
global_system_variables.lc_messages= my_default_lc_messages;
|
||||
|
||||
if (init_errmessage()) /* Read error messages from file */
|
||||
return 1;
|
||||
global_system_variables.lc_messages= my_default_lc_messages;
|
||||
global_system_variables.errmsgs= my_default_lc_messages->errmsgs->errmsgs;
|
||||
init_client_errs();
|
||||
mysql_library_init(unused,unused,unused); /* for replication */
|
||||
lex_init();
|
||||
|
@@ -644,6 +644,8 @@ typedef struct system_variables
|
||||
|
||||
/* Error messages */
|
||||
MY_LOCALE *lc_messages;
|
||||
const char **errmsgs; /* lc_messages->errmsg->errmsgs */
|
||||
|
||||
/* Locale Support */
|
||||
MY_LOCALE *lc_time_names;
|
||||
|
||||
|
@@ -4587,11 +4587,22 @@ static bool check_locale(sys_var *self, THD *thd, set_var *var)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool update_locale(sys_var *self, THD* thd, enum_var_type type)
|
||||
{
|
||||
/* Cache pointer to error messages */
|
||||
if (type == OPT_SESSION)
|
||||
thd->variables.errmsgs= thd->variables.lc_messages->errmsgs->errmsgs;
|
||||
else
|
||||
global_system_variables.errmsgs=
|
||||
global_system_variables.lc_messages->errmsgs->errmsgs;
|
||||
return false;
|
||||
}
|
||||
|
||||
static Sys_var_struct Sys_lc_messages(
|
||||
"lc_messages", "Set the language used for the error messages",
|
||||
SESSION_VAR(lc_messages), NO_CMD_LINE,
|
||||
my_offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_messages),
|
||||
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_locale));
|
||||
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_locale), ON_UPDATE(update_locale));
|
||||
|
||||
static Sys_var_struct Sys_lc_time_names(
|
||||
"lc_time_names", "Set the language used for the month "
|
||||
|
@@ -43,15 +43,14 @@
|
||||
#define PLUGINDIR "lib/plugin"
|
||||
#endif
|
||||
|
||||
#define CURRENT_THD_ERRMSGS current_thd->variables.lc_messages->errmsgs->errmsgs
|
||||
#define CURRENT_THD_ERRMSGS current_thd->variables.errmsgs
|
||||
#define DEFAULT_ERRMSGS my_default_lc_messages->errmsgs->errmsgs
|
||||
|
||||
#define ER(X) CURRENT_THD_ERRMSGS[(X) - ER_ERROR_FIRST]
|
||||
#define ER_DEFAULT(X) DEFAULT_ERRMSGS[(X) - ER_ERROR_FIRST]
|
||||
#define ER_SAFE(X) (((X) >= ER_ERROR_FIRST && (X) <= ER_ERROR_LAST) ? ER(X) : "Invalid error code")
|
||||
#define ER_SAFE_THD(T,X) (((X) >= ER_ERROR_FIRST && (X) <= ER_ERROR_LAST) ? ER_THD(T,X) : "Invalid error code")
|
||||
#define ER_THD(thd,X) ((thd)->variables.lc_messages->errmsgs->errmsgs[(X) - \
|
||||
ER_ERROR_FIRST])
|
||||
#define ER_THD(thd,X) ((thd)->variables.errmsgs[(X) - ER_ERROR_FIRST])
|
||||
#define ER_THD_OR_DEFAULT(thd,X) ((thd) ? ER_THD(thd, X) : ER_DEFAULT(X))
|
||||
|
||||
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
|
||||
|
Reference in New Issue
Block a user