struct field data type improvement for memory usage.
This commit is contained in:
parent
da47f06bdc
commit
ef9962c958
3 changed files with 31 additions and 17 deletions
|
@ -526,3 +526,14 @@
|
|||
1400923315,10840939.91,4663256.98,55924.05,2611667.47
|
||||
1400923325,11091416.01,4103660.70,59074.70,2817256.97
|
||||
1400923335,11435046.07,4356917.52,45100.04,2883103.51
|
||||
1400928121,11717285.79,4816672.70,58254.22,2897866.52
|
||||
1400928131,11343621.37,4759351.32,45100.04,2849262.65
|
||||
1400928141,11268332.55,4717279.18,55188.21,2871378.81
|
||||
1400928151,11308055.40,4652350.21,47662.55,2866742.89
|
||||
1400928225,10802915.60,4687267.34,58254.22,2632936.94
|
||||
1400928235,10661874.62,4739682.52,62601.55,2740810.88
|
||||
1400928262,11033784.15,4714416.68,55188.21,2737984.12
|
||||
1400928272,10649279.69,4567955.12,47662.55,2716598.01
|
||||
1400928308,9831622.81,4277888.23,45590.26,2421364.56
|
||||
1400928319,10230059.66,4527332.79,49932.19,2345303.39
|
||||
1400928329,11085172.21,4647514.08,62601.55,2735715.15
|
||||
|
|
Can't render this file because it has a wrong number of fields in line 447.
|
17
include/r3.h
17
include/r3.h
|
@ -35,13 +35,12 @@ struct _node {
|
|||
// almost less than 255
|
||||
unsigned char edge_len;
|
||||
unsigned char edge_cap;
|
||||
|
||||
unsigned char compare_type;
|
||||
unsigned char endpoint;
|
||||
unsigned char ov_cnt;
|
||||
|
||||
// <-- here comes a char[3] struct padding for alignment since we have 5 char above.
|
||||
|
||||
// almost less than 255
|
||||
unsigned char route_len;
|
||||
unsigned char route_cap;
|
||||
|
||||
/** compile-time variables here.... **/
|
||||
|
||||
|
@ -51,6 +50,10 @@ struct _node {
|
|||
|
||||
char * combined_pattern;
|
||||
|
||||
// almost less than 255
|
||||
unsigned char route_len;
|
||||
unsigned char route_cap;
|
||||
|
||||
/**
|
||||
* the pointer of route data
|
||||
*/
|
||||
|
@ -60,9 +63,9 @@ struct _node {
|
|||
struct _edge {
|
||||
char * pattern;
|
||||
node * child;
|
||||
unsigned char opcode;
|
||||
unsigned short pattern_len;
|
||||
bool has_slug:1;
|
||||
unsigned short pattern_len; // 2 byte
|
||||
unsigned char opcode; // 1 byte
|
||||
unsigned char has_slug; // 1 bit
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
20
src/node.c
20
src/node.c
|
@ -196,6 +196,8 @@ void r3_tree_compile_patterns(node * n) {
|
|||
int erroffset;
|
||||
unsigned int option_bits = 0;
|
||||
|
||||
n->ov_cnt = (1 + n->edge_len) * 3;
|
||||
|
||||
if (n->pcre_pattern) {
|
||||
pcre_free(n->pcre_pattern);
|
||||
}
|
||||
|
@ -254,17 +256,12 @@ node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * e
|
|||
info("try matching: %s\n", path);
|
||||
|
||||
edge *e;
|
||||
char rc;
|
||||
unsigned short i;
|
||||
unsigned short ov_cnt;
|
||||
unsigned short restlen;
|
||||
char *pp;
|
||||
char *pp_end = path + path_len;
|
||||
|
||||
char *substring_start = NULL;
|
||||
int substring_length = 0;
|
||||
|
||||
if (n->compare_type == NODE_COMPARE_OPCODE) {
|
||||
char *pp;
|
||||
char *pp_end = path + path_len;
|
||||
for (i = 0; i < n->edge_len ; i++ ) {
|
||||
pp = path;
|
||||
e = n->edges[i];
|
||||
|
@ -302,9 +299,12 @@ node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * e
|
|||
// if the pcre_pattern is found, and the pointer is not NULL, then it's
|
||||
// pcre pattern node, we use pcre_exec to match the nodes
|
||||
if (n->pcre_pattern) {
|
||||
char *substring_start = NULL;
|
||||
int substring_length = 0;
|
||||
int ov[ n->ov_cnt ];
|
||||
char rc;
|
||||
|
||||
info("pcre matching %s on %s\n", n->combined_pattern, path);
|
||||
ov_cnt = (1 + n->edge_len) * 3;
|
||||
int ov[ ov_cnt ];
|
||||
|
||||
rc = pcre_exec(
|
||||
n->pcre_pattern, /* the compiled pattern */
|
||||
|
@ -314,7 +314,7 @@ node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * e
|
|||
0, /* start at offset 0 in the subject */
|
||||
0, /* default options */
|
||||
ov, /* output vector for substring information */
|
||||
ov_cnt); /* number of elements in the output vector */
|
||||
n->ov_cnt); /* number of elements in the output vector */
|
||||
|
||||
// does not match all edges, return NULL;
|
||||
if (rc < 0) {
|
||||
|
|
Loading…
Reference in a new issue