forked from github/server
Merge pull request #673 from ennorehling/profile-hashstring
speed up some code based on profiling
This commit is contained in:
commit
66a0bc83e5
|
@ -178,8 +178,8 @@ struct order *ord)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BAGPIPEFRACTION dice_rand("2d4+2")
|
#define BAGPIPEFRACTION (dice(2,4)+2)
|
||||||
#define BAGPIPEDURATION dice_rand("2d10+4")
|
#define BAGPIPEDURATION (dice(2,10)+4)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
use_bagpipeoffear(struct unit *u, const struct item_type *itype,
|
use_bagpipeoffear(struct unit *u, const struct item_type *itype,
|
||||||
|
|
|
@ -1217,7 +1217,7 @@ void terraform_region(region * r, const terrain_type * terrain)
|
||||||
|
|
||||||
if (!fval(r, RF_CHAOTIC)) {
|
if (!fval(r, RF_CHAOTIC)) {
|
||||||
int peasants;
|
int peasants;
|
||||||
peasants = (region_maxworkers(r) * (20 + dice_rand("6d10"))) / 100;
|
peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100;
|
||||||
rsetpeasants(r, MAX(100, peasants));
|
rsetpeasants(r, MAX(100, peasants));
|
||||||
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
|
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
|
||||||
INT_MAX) + 1) + rng_int() % 5));
|
INT_MAX) + 1) + rng_int() % 5));
|
||||||
|
|
|
@ -81,7 +81,7 @@ static crmessage_type *crtypes[CRMAXHASH];
|
||||||
|
|
||||||
static crmessage_type *crt_find(const struct message_type *mtype)
|
static crmessage_type *crt_find(const struct message_type *mtype)
|
||||||
{
|
{
|
||||||
unsigned int hash = hashstring(mtype->name) % CRMAXHASH;
|
unsigned int hash = mtype->key % CRMAXHASH;
|
||||||
crmessage_type *found = NULL;
|
crmessage_type *found = NULL;
|
||||||
crmessage_type *type = crtypes[hash];
|
crmessage_type *type = crtypes[hash];
|
||||||
while (type) {
|
while (type) {
|
||||||
|
@ -94,7 +94,7 @@ static crmessage_type *crt_find(const struct message_type *mtype)
|
||||||
|
|
||||||
void crt_register(const struct message_type *mtype)
|
void crt_register(const struct message_type *mtype)
|
||||||
{
|
{
|
||||||
unsigned int hash = hashstring(mtype->name) % CRMAXHASH;
|
unsigned int hash = mtype->key % CRMAXHASH;
|
||||||
crmessage_type *crt = crtypes[hash];
|
crmessage_type *crt = crtypes[hash];
|
||||||
while (crt && crt->mtype != mtype) {
|
while (crt && crt->mtype != mtype) {
|
||||||
crt = crt->next;
|
crt = crt->next;
|
||||||
|
|
|
@ -40,7 +40,7 @@ nrmessage_type *nrt_find(const struct locale * lang,
|
||||||
const struct message_type * mtype)
|
const struct message_type * mtype)
|
||||||
{
|
{
|
||||||
nrmessage_type *found = NULL;
|
nrmessage_type *found = NULL;
|
||||||
unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH;
|
unsigned int hash = mtype->key % NRT_MAXHASH;
|
||||||
nrmessage_type *type = nrtypes[hash];
|
nrmessage_type *type = nrtypes[hash];
|
||||||
while (type) {
|
while (type) {
|
||||||
if (type->mtype == mtype) {
|
if (type->mtype == mtype) {
|
||||||
|
@ -101,7 +101,7 @@ void
|
||||||
nrt_register(const struct message_type *mtype, const struct locale *lang,
|
nrt_register(const struct message_type *mtype, const struct locale *lang,
|
||||||
const char *string, int level, const char *section)
|
const char *string, int level, const char *section)
|
||||||
{
|
{
|
||||||
unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH;
|
unsigned int hash = mtype->key % NRT_MAXHASH;
|
||||||
nrmessage_type *nrt = nrtypes[hash];
|
nrmessage_type *nrt = nrtypes[hash];
|
||||||
while (nrt && (nrt->lang != lang || nrt->mtype != mtype)) {
|
while (nrt && (nrt->lang != lang || nrt->mtype != mtype)) {
|
||||||
nrt = nrt->next;
|
nrt = nrt->next;
|
||||||
|
|
|
@ -3,7 +3,6 @@ IF EXIST ..\build-vs10 SET BUILD=..\build-vs10\eressea\Debug
|
||||||
IF EXIST ..\build-vs11 SET BUILD=..\build-vs11\eressea\Debug
|
IF EXIST ..\build-vs11 SET BUILD=..\build-vs11\eressea\Debug
|
||||||
IF EXIST ..\build-vs12 SET BUILD=..\build-vs12\eressea\Debug
|
IF EXIST ..\build-vs12 SET BUILD=..\build-vs12\eressea\Debug
|
||||||
IF EXIST ..\build-vs14 SET BUILD=..\build-vs14\eressea\Debug
|
IF EXIST ..\build-vs14 SET BUILD=..\build-vs14\eressea\Debug
|
||||||
IF EXIST ..\build-vs15 SET BUILD=..\build-vs15\eressea\Debug
|
|
||||||
SET SERVER=%BUILD%\eressea.exe
|
SET SERVER=%BUILD%\eressea.exe
|
||||||
%BUILD%\test_eressea.exe
|
%BUILD%\test_eressea.exe
|
||||||
%SERVER% ..\scripts\run-tests.lua
|
%SERVER% ..\scripts\run-tests.lua
|
||||||
|
|
Loading…
Reference in New Issue