aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/tsrank.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-01-18 16:04:11 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2014-01-18 16:04:32 -0500
commit0d79c0a8cc20dbaa39112d78a9abb821c4ca3554 (patch)
treefbf44e5fc488b94c056aead354111d4e32167318 /src/backend/utils/adt/tsrank.c
parent7d7eee8bb702d7796a0d7c5886c1f4685f2e2806 (diff)
downloadpostgresql-0d79c0a8cc20dbaa39112d78a9abb821c4ca3554.tar.gz
postgresql-0d79c0a8cc20dbaa39112d78a9abb821c4ca3554.zip
Make various variables const (read-only).
These changes should generally improve correctness/maintainability. A nice side benefit is that several kilobytes move from initialized data to text segment, allowing them to be shared across processes and probably reducing copy-on-write overhead while forking a new backend. Unfortunately this doesn't seem to help libpq in the same way (at least not when it's compiled with -fpic on x86_64), but we can hope the linker at least collects all nominally-const data together even if it's not actually part of the text segment. Also, make pg_encname_tbl[] static in encnames.c, since there seems no very good reason for any other code to use it; per a suggestion from Wim Lewis, who independently submitted a patch that was mostly a subset of this one. Oskari Saarenmaa, with some editorialization by me
Diffstat (limited to 'src/backend/utils/adt/tsrank.c')
-rw-r--r--src/backend/utils/adt/tsrank.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c
index a8e07e7fbc2..c9e71c9e21d 100644
--- a/src/backend/utils/adt/tsrank.c
+++ b/src/backend/utils/adt/tsrank.c
@@ -20,7 +20,7 @@
#include "miscadmin.h"
-static float weights[] = {0.1f, 0.2f, 0.4f, 1.0f};
+static const float weights[] = {0.1f, 0.2f, 0.4f, 1.0f};
#define wpos(wep) ( w[ WEP_GETWEIGHT(wep) ] )
@@ -33,8 +33,8 @@ static float weights[] = {0.1f, 0.2f, 0.4f, 1.0f};
#define RANK_NORM_RDIVRPLUS1 0x20
#define DEF_NORM_METHOD RANK_NO_NORM
-static float calc_rank_or(float *w, TSVector t, TSQuery q);
-static float calc_rank_and(float *w, TSVector t, TSQuery q);
+static float calc_rank_or(const float *w, TSVector t, TSQuery q);
+static float calc_rank_and(const float *w, TSVector t, TSQuery q);
/*
* Returns a weight of a word collocation
@@ -202,7 +202,7 @@ static WordEntryPosVector POSNULL = {
};
static float
-calc_rank_and(float *w, TSVector t, TSQuery q)
+calc_rank_and(const float *w, TSVector t, TSQuery q)
{
WordEntryPosVector **pos;
int i,
@@ -278,7 +278,7 @@ calc_rank_and(float *w, TSVector t, TSQuery q)
}
static float
-calc_rank_or(float *w, TSVector t, TSQuery q)
+calc_rank_or(const float *w, TSVector t, TSQuery q)
{
WordEntry *entry,
*firstentry;
@@ -347,7 +347,7 @@ calc_rank_or(float *w, TSVector t, TSQuery q)
}
static float
-calc_rank(float *w, TSVector t, TSQuery q, int32 method)
+calc_rank(const float *w, TSVector t, TSQuery q, int32 method)
{
QueryItem *item = GETQUERY(q);
float res = 0.0;
@@ -387,7 +387,7 @@ calc_rank(float *w, TSVector t, TSQuery q, int32 method)
return res;
}
-static float *
+static const float *
getWeights(ArrayType *win)
{
static float ws[lengthof(weights)];
@@ -723,7 +723,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
}
static float4
-calc_rank_cd(float4 *arrdata, TSVector txt, TSQuery query, int method)
+calc_rank_cd(const float4 *arrdata, TSVector txt, TSQuery query, int method)
{
DocRepresentation *doc;
int len,