Const-ify a few more large static tables.
Per research by Andres. Discussion: https://postgr.es/m/20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de
This commit is contained in:
parent
9958b2b2a8
commit
48d818ede1
@ -165,7 +165,7 @@ static const datetkn datetktbl[] = {
|
|||||||
{YESTERDAY, RESERV, DTK_YESTERDAY} /* yesterday midnight */
|
{YESTERDAY, RESERV, DTK_YESTERDAY} /* yesterday midnight */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0];
|
static const int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* deltatktbl: same format as datetktbl, but holds keywords used to represent
|
* deltatktbl: same format as datetktbl, but holds keywords used to represent
|
||||||
@ -238,7 +238,7 @@ static const datetkn deltatktbl[] = {
|
|||||||
{"yrs", UNITS, DTK_YEAR} /* "years" relative */
|
{"yrs", UNITS, DTK_YEAR} /* "years" relative */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0];
|
static const int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0];
|
||||||
|
|
||||||
static TimeZoneAbbrevTable *zoneabbrevtbl = NULL;
|
static TimeZoneAbbrevTable *zoneabbrevtbl = NULL;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
static struct
|
static const struct
|
||||||
{
|
{
|
||||||
unsigned short int nec; /* SJIS UDC (NEC selection IBM kanji) */
|
unsigned short int nec; /* SJIS UDC (NEC selection IBM kanji) */
|
||||||
unsigned short int sjis; /* SJIS UDC (IBM kanji) */
|
unsigned short int sjis; /* SJIS UDC (IBM kanji) */
|
||||||
|
@ -336,6 +336,6 @@ extern char *pgtypes_date_weekdays_short[];
|
|||||||
extern char *pgtypes_date_months[];
|
extern char *pgtypes_date_months[];
|
||||||
extern char *months[];
|
extern char *months[];
|
||||||
extern char *days[];
|
extern char *days[];
|
||||||
extern int day_tab[2][13];
|
extern const int day_tab[2][13];
|
||||||
|
|
||||||
#endif /* DT_H */
|
#endif /* DT_H */
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
#include "dt.h"
|
#include "dt.h"
|
||||||
#include "pgtypes_timestamp.h"
|
#include "pgtypes_timestamp.h"
|
||||||
|
|
||||||
int day_tab[2][13] = {
|
const int day_tab[2][13] = {
|
||||||
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
|
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
|
||||||
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}};
|
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}};
|
||||||
|
|
||||||
typedef long AbsoluteTime;
|
typedef long AbsoluteTime;
|
||||||
|
|
||||||
static datetkn datetktbl[] = {
|
static const datetkn datetktbl[] = {
|
||||||
/* text, token, lexval */
|
/* text, token, lexval */
|
||||||
{EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
|
{EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
|
||||||
{"acsst", DTZ, 37800}, /* Cent. Australia */
|
{"acsst", DTZ, 37800}, /* Cent. Australia */
|
||||||
@ -420,7 +420,7 @@ static datetkn datetktbl[] = {
|
|||||||
{ZULU, TZ, 0}, /* UTC */
|
{ZULU, TZ, 0}, /* UTC */
|
||||||
};
|
};
|
||||||
|
|
||||||
static datetkn deltatktbl[] = {
|
static const datetkn deltatktbl[] = {
|
||||||
/* text, token, lexval */
|
/* text, token, lexval */
|
||||||
{"@", IGNORE_DTF, 0}, /* postgres relative prefix */
|
{"@", IGNORE_DTF, 0}, /* postgres relative prefix */
|
||||||
{DAGO, AGO, 0}, /* "ago" indicates negative time offset */
|
{DAGO, AGO, 0}, /* "ago" indicates negative time offset */
|
||||||
@ -490,9 +490,9 @@ static datetkn deltatktbl[] = {
|
|||||||
static const unsigned int szdatetktbl = lengthof(datetktbl);
|
static const unsigned int szdatetktbl = lengthof(datetktbl);
|
||||||
static const unsigned int szdeltatktbl = lengthof(deltatktbl);
|
static const unsigned int szdeltatktbl = lengthof(deltatktbl);
|
||||||
|
|
||||||
static datetkn *datecache[MAXDATEFIELDS] = {NULL};
|
static const datetkn *datecache[MAXDATEFIELDS] = {NULL};
|
||||||
|
|
||||||
static datetkn *deltacache[MAXDATEFIELDS] = {NULL};
|
static const datetkn *deltacache[MAXDATEFIELDS] = {NULL};
|
||||||
|
|
||||||
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
|
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
|
||||||
|
|
||||||
@ -502,12 +502,12 @@ char *pgtypes_date_weekdays_short[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fr
|
|||||||
|
|
||||||
char *pgtypes_date_months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", NULL};
|
char *pgtypes_date_months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", NULL};
|
||||||
|
|
||||||
static datetkn *
|
static const datetkn *
|
||||||
datebsearch(char *key, datetkn *base, unsigned int nel)
|
datebsearch(const char *key, const datetkn *base, unsigned int nel)
|
||||||
{
|
{
|
||||||
if (nel > 0)
|
if (nel > 0)
|
||||||
{
|
{
|
||||||
datetkn *last = base + nel - 1,
|
const datetkn *last = base + nel - 1,
|
||||||
*position;
|
*position;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@ -540,7 +540,7 @@ int
|
|||||||
DecodeUnits(int field, char *lowtoken, int *val)
|
DecodeUnits(int field, char *lowtoken, int *val)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
datetkn *tp;
|
const datetkn *tp;
|
||||||
|
|
||||||
/* use strncmp so that we match truncated tokens */
|
/* use strncmp so that we match truncated tokens */
|
||||||
if (deltacache[field] != NULL &&
|
if (deltacache[field] != NULL &&
|
||||||
@ -641,7 +641,7 @@ static int
|
|||||||
DecodeSpecial(int field, char *lowtoken, int *val)
|
DecodeSpecial(int field, char *lowtoken, int *val)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
datetkn *tp;
|
const datetkn *tp;
|
||||||
|
|
||||||
/* use strncmp so that we match truncated tokens */
|
/* use strncmp so that we match truncated tokens */
|
||||||
if (datecache[field] != NULL &&
|
if (datecache[field] != NULL &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user