Skip to content

Commit 341eed5

Browse files
committed
remove unused functions/move macroses
1 parent 4d94911 commit 341eed5

File tree

3 files changed

+47
-65
lines changed

3 files changed

+47
-65
lines changed

jsquery.h

+36-47
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,6 @@ typedef enum JsQueryItemType {
5454
jqiIn = 'I'
5555
} JsQueryItemType;
5656

57-
typedef struct JsQueryItem JsQueryItem;
58-
59-
struct JsQueryItem {
60-
JsQueryItemType type;
61-
JsQueryItem *next; /* next in path */
62-
63-
union {
64-
struct {
65-
JsQueryItem *left;
66-
JsQueryItem *right;
67-
} args;
68-
69-
JsQueryItem *arg;
70-
71-
Numeric numeric;
72-
bool boolean;
73-
struct {
74-
uint32 len;
75-
char *val; /* could not be not null-terminated */
76-
} string;
77-
78-
struct {
79-
int nelems;
80-
JsQueryItem **elems;
81-
} array;
82-
};
83-
};
84-
8557
typedef struct JsQueryItemR {
8658
JsQueryItemType type;
8759
int32 nextPos;
@@ -121,34 +93,49 @@ extern void jsqIterateInit(JsQueryItemR *v);
12193
extern bool jsqIterateArray(JsQueryItemR *v, JsQueryItemR *e);
12294

12395
/*
124-
* support
96+
* Parsing
12597
*/
12698

127-
extern JsQueryItem* parsejsquery(const char *str, int len);
99+
typedef struct JsQueryItem JsQueryItem;
128100

129-
int32 readJsQueryHeader(char *base, int32 pos, JsQueryItemType *type, int32 *nextPos);
101+
struct JsQueryItem {
102+
JsQueryItemType type;
103+
JsQueryItem *next; /* next in path */
130104

131-
#define read_byte(v, b, p) do { \
132-
(v) = *(int8*)((b) + (p)); \
133-
(p) += 1; \
134-
} while(0) \
105+
union {
106+
struct {
107+
JsQueryItem *left;
108+
JsQueryItem *right;
109+
} args;
135110

136-
#define read_int32(v, b, p) do { \
137-
(v) = *(int32*)((b) + (p)); \
138-
(p) += sizeof(int32); \
139-
} while(0) \
111+
JsQueryItem *arg;
112+
113+
Numeric numeric;
114+
bool boolean;
115+
struct {
116+
uint32 len;
117+
char *val; /* could not be not null-terminated */
118+
} string;
119+
120+
struct {
121+
int nelems;
122+
JsQueryItem **elems;
123+
} array;
124+
};
125+
};
126+
127+
extern JsQueryItem* parsejsquery(const char *str, int len);
140128

141129
void alignStringInfoInt(StringInfo buf);
142-
#endif
143130

144131
/* jsquery_extract.c */
145132

146133
typedef enum
147134
{
148-
iAny = 1,
149-
iAnyArray,
150-
iKey,
151-
iAnyKey
135+
iAny = jqiAny,
136+
iAnyArray = jqiAnyArray,
137+
iKey = jqiKey,
138+
iAnyKey = jqiAnyKey
152139
} PathItemType;
153140

154141
typedef struct PathItem PathItem;
@@ -163,9 +150,9 @@ struct PathItem
163150
typedef enum
164151
{
165152
eScalar = 1,
166-
eAnd,
167-
eOr,
168-
eNot
153+
eAnd = jqiAnd,
154+
eOr = jqiOr,
155+
eNot = jqiNot
169156
} ExtractedNodeType;
170157

171158
typedef struct ExtractedNode ExtractedNode;
@@ -199,3 +186,5 @@ typedef int (*MakeEntryHandler)(ExtractedNode *node, Pointer extra);
199186
ExtractedNode *extractJsQuery(JsQuery *jq, MakeEntryHandler handler, Pointer extra);
200187
bool execRecursive(ExtractedNode *node, bool *check);
201188
bool execRecursiveTristate(ExtractedNode *node, GinTernaryValue *check);
189+
190+
#endif

jsquery_io.c

-17
Original file line numberDiff line numberDiff line change
@@ -165,23 +165,6 @@ jsquery_in(PG_FUNCTION_ARGS)
165165
PG_RETURN_NULL();
166166
}
167167

168-
int32
169-
readJsQueryHeader(char *base, int32 pos, JsQueryItemType *type, int32 *nextPos)
170-
{
171-
read_byte(*type, base, pos);
172-
switch(INTALIGN(pos) - pos)
173-
{
174-
case 3: pos++;
175-
case 2: pos++;
176-
case 1: pos++;
177-
default: break;
178-
}
179-
read_int32(*nextPos, base, pos);
180-
181-
return pos;
182-
}
183-
184-
185168
static void
186169
printOperation(StringInfo buf, JsQueryItemType type)
187170
{

jsquery_support.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616

1717
#include "jsquery.h"
1818

19+
#define read_byte(v, b, p) do { \
20+
(v) = *(int8*)((b) + (p)); \
21+
(p) += 1; \
22+
} while(0) \
23+
24+
#define read_int32(v, b, p) do { \
25+
(v) = *(int32*)((b) + (p)); \
26+
(p) += sizeof(int32); \
27+
} while(0) \
28+
1929
void
2030
jsqInit(JsQueryItemR *v, JsQuery *js)
2131
{
@@ -78,7 +88,7 @@ jsqInitByBuffer(JsQueryItemR *v, char *base, int32 pos)
7888
read_int32(v->arg, base, pos);
7989
break;
8090
default:
81-
elog(ERROR, "Unknown JsQueryItem type: %d", v->type);
91+
elog(ERROR, "Unknown type: %d", v->type);
8292
}
8393
}
8494

0 commit comments

Comments
 (0)