Skip to content

Commit

Permalink
Merge pull request #891 from sjinks/reorder-fields
Browse files Browse the repository at this point in the history
[NFR] Reorder struct fields to save some memory
  • Loading branch information
Phalcon committed Jul 22, 2013
2 parents 59f350e + 4d29835 commit c0378c0
Show file tree
Hide file tree
Showing 17 changed files with 355 additions and 351 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
.project
unit-tests/engines/*
unit-tests/logs/*
unit-tests/cache/2e11fab3b6861010be11a5deb92bddff
unit-tests/cache/7ea1207f9d82bf4982cf5e1aec693375
unit-tests/cache/*
build/.deps
build/.libs/
build/Makefile
Expand Down Expand Up @@ -471,6 +470,7 @@ ext/mvc/router/group.lo
unit-tests/annotations/cache/*.php
*.o
*.lo
*.loT
.libs
build/t.dSYM/
build/install2
Expand Down
6 changes: 3 additions & 3 deletions ext/annotations/annot.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
*/

typedef struct _phannot_parser_token {
int opcode;
char *token;
int opcode;
int token_len;
int free_flag;
} phannot_parser_token;

typedef struct _phannot_parser_status {
int status;
zval *ret;
phannot_scanner_state *scanner_state;
phannot_scanner_token *token;
char *syntax_error;
int status;
zend_uint syntax_error_len;
char *syntax_error;
} phannot_parser_status;

#define PHANNOT_PARSING_OK 1
Expand Down
34 changes: 17 additions & 17 deletions ext/annotations/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@

const phannot_token_names phannot_tokens[] =
{
{ PHANNOT_T_INTEGER, "INTEGER" },
{ PHANNOT_T_DOUBLE, "DOUBLE" },
{ PHANNOT_T_STRING, "STRING" },
{ PHANNOT_T_IDENTIFIER, "IDENTIFIER" },
{ PHANNOT_T_AT, "@" },
{ PHANNOT_T_COMMA, "," },
{ PHANNOT_T_EQUALS, "=" },
{ PHANNOT_T_COLON, ":" },
{ PHANNOT_T_PARENTHESES_OPEN, "(" },
{ PHANNOT_T_PARENTHESES_CLOSE, ")" },
{ PHANNOT_T_BRACKET_OPEN, "{" },
{ PHANNOT_T_BRACKET_CLOSE, "}" },
{ PHANNOT_T_SBRACKET_OPEN, "[" },
{ PHANNOT_T_SBRACKET_CLOSE, "]" },
{ PHANNOT_T_ARBITRARY_TEXT, "ARBITRARY TEXT" },
{ 0, NULL }
{ "INTEGER", PHANNOT_T_INTEGER },
{ "DOUBLE", PHANNOT_T_DOUBLE },
{ "STRING", PHANNOT_T_STRING },
{ "IDENTIFIER", PHANNOT_T_IDENTIFIER },
{ "@", PHANNOT_T_AT },
{ ",", PHANNOT_T_COMMA },
{ "=", PHANNOT_T_EQUALS },
{ ":", PHANNOT_T_COLON },
{ "(", PHANNOT_T_PARENTHESES_OPEN },
{ ")", PHANNOT_T_PARENTHESES_CLOSE },
{ "{", PHANNOT_T_BRACKET_OPEN },
{ "}", PHANNOT_T_BRACKET_CLOSE },
{ "[", PHANNOT_T_SBRACKET_OPEN },
{ "]", PHANNOT_T_SBRACKET_CLOSE },
{ "ARBITRARY TEXT", PHANNOT_T_ARBITRARY_TEXT },
{ NULL, 0 }
};

/**
Expand Down Expand Up @@ -434,4 +434,4 @@ int phannot_internal_parse_annotations(zval **result, zval *comment, zval *file_
efree(state);

return status;
}
}
34 changes: 17 additions & 17 deletions ext/annotations/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1207,22 +1207,22 @@ void phannot_(

const phannot_token_names phannot_tokens[] =
{
{ PHANNOT_T_INTEGER, "INTEGER" },
{ PHANNOT_T_DOUBLE, "DOUBLE" },
{ PHANNOT_T_STRING, "STRING" },
{ PHANNOT_T_IDENTIFIER, "IDENTIFIER" },
{ PHANNOT_T_AT, "@" },
{ PHANNOT_T_COMMA, "," },
{ PHANNOT_T_EQUALS, "=" },
{ PHANNOT_T_COLON, ":" },
{ PHANNOT_T_PARENTHESES_OPEN, "(" },
{ PHANNOT_T_PARENTHESES_CLOSE, ")" },
{ PHANNOT_T_BRACKET_OPEN, "{" },
{ PHANNOT_T_BRACKET_CLOSE, "}" },
{ PHANNOT_T_SBRACKET_OPEN, "[" },
{ PHANNOT_T_SBRACKET_CLOSE, "]" },
{ PHANNOT_T_ARBITRARY_TEXT, "ARBITRARY TEXT" },
{ 0, NULL }
{ "INTEGER", PHANNOT_T_INTEGER },
{ "DOUBLE", PHANNOT_T_DOUBLE },
{ "STRING", PHANNOT_T_STRING },
{ "IDENTIFIER", PHANNOT_T_IDENTIFIER },
{ "@", PHANNOT_T_AT },
{ ",", PHANNOT_T_COMMA },
{ "=", PHANNOT_T_EQUALS },
{ ":", PHANNOT_T_COLON },
{ "(", PHANNOT_T_PARENTHESES_OPEN },
{ ")", PHANNOT_T_PARENTHESES_CLOSE },
{ "{", PHANNOT_T_BRACKET_OPEN },
{ "}", PHANNOT_T_BRACKET_CLOSE },
{ "[", PHANNOT_T_SBRACKET_OPEN },
{ "]", PHANNOT_T_SBRACKET_CLOSE },
{ "ARBITRARY TEXT", PHANNOT_T_ARBITRARY_TEXT },
{ NULL, 0 }
};

/**
Expand Down Expand Up @@ -1622,4 +1622,4 @@ int phannot_internal_parse_annotations(zval **result, zval *comment, zval *file_
efree(state);

return status;
}
}
6 changes: 3 additions & 3 deletions ext/annotations/scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@

/* List of tokens and their names */
typedef struct _phannot_token_names {
unsigned int code;
char *name;
unsigned int code;
} phannot_token_names;

/* Active token state */
typedef struct _phannot_scanner_state {
int active_token;
char* start;
char* end;
int active_token;
unsigned int start_length;
int mode;
unsigned int active_line;
Expand All @@ -73,8 +73,8 @@ typedef struct _phannot_scanner_state {

/* Extra information tokens */
typedef struct _phannot_scanner_token {
int opcode;
char *value;
int opcode;
int len;
} phannot_scanner_token;

Expand Down
4 changes: 3 additions & 1 deletion ext/assets/filters/cssminifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ typedef struct _cssmin_parser {
int in_paren;
zval *style;
zval **error;
smart_str *minified;
int style_pointer;
smart_str *minified;
} cssmin_parser;

/* get -- return the next character from stdin. Watch out for lookahead. If
Expand Down Expand Up @@ -116,6 +116,7 @@ static int phalcon_cssmin_machine(cssmin_parser *parser, unsigned char c TSRMLS_
//fprintf(stdout,"one to 3 - %c %i",c,c);
parser->state = STATE_SELECTOR;
}
/* no break */
case STATE_SELECTOR:
if (c == '{') {
parser->state = STATE_BLOCK;
Expand Down Expand Up @@ -170,6 +171,7 @@ static int phalcon_cssmin_machine(cssmin_parser *parser, unsigned char c TSRMLS_
parser->state = STATE_DECLARATION;
}
}
/* no break */
case STATE_DECLARATION:
/**
* support in paren because data can uris have ;
Expand Down
14 changes: 8 additions & 6 deletions ext/assets/filters/jsminifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ SOFTWARE.
#define JSMIN_ACTION_NEXT 3

typedef struct _jsmin_parser {
zval *script;
zval **error;
int script_pointer;
int inside_string;
smart_str *minified;
char theA;
char theB;
char theC;
char theX;
char theY;
zval *script;
zval **error;
int script_pointer;
int inside_string;
smart_str *minified;
} jsmin_parser;

static void jsmin_error(jsmin_parser *parser, char* s, int s_length TSRMLS_DC) {
Expand Down Expand Up @@ -170,6 +170,7 @@ static int jsmin_action(jsmin_parser *parser, char d TSRMLS_DC) {
) {
smart_str_appendc(parser->minified, parser->theY);
}
/* no break */
case JSMIN_ACTION_NEXT_DELETE:
parser->theA = parser->theB;
if (parser->theA == '\'' || parser->theA == '"' || parser->theA == '`') {
Expand All @@ -191,6 +192,7 @@ static int jsmin_action(jsmin_parser *parser, char d TSRMLS_DC) {
}
parser->inside_string = 0;
}
/* no break */
case JSMIN_ACTION_NEXT:
parser->theB = jsmin_next(parser TSRMLS_CC);
if (*parser->error != NULL) {
Expand Down Expand Up @@ -398,4 +400,4 @@ int phalcon_jsmin(zval *return_value, zval *script TSRMLS_DC) {
}

return SUCCESS;
}
}
4 changes: 2 additions & 2 deletions ext/kernel/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
#define PHPR(v) phalcon_print_r(v)

typedef struct _phalcon_debug_entry {
struct _phalcon_debug_entry *prev;
struct _phalcon_debug_entry *next;
char *class_name;
char *method_name;
int lineno;
struct _phalcon_debug_entry *prev;
struct _phalcon_debug_entry *next;
} phalcon_debug_entry;

extern int phalcon_start_debug();
Expand Down
136 changes: 68 additions & 68 deletions ext/mvc/model/query/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,73 +19,73 @@

const phql_token_names phql_tokens[] =
{
{ PHQL_T_INTEGER, SL("INTEGER") },
{ PHQL_T_DOUBLE, SL("DOUBLE") },
{ PHQL_T_STRING, SL("STRING") },
{ PHQL_T_IDENTIFIER, SL("IDENTIFIER") },
{ PHQL_T_MINUS, SL("MINUS") },
{ PHQL_T_ADD, SL("+") },
{ PHQL_T_SUB, SL("-") },
{ PHQL_T_MUL, SL("*") },
{ PHQL_T_DIV, SL("/") },
{ PHQL_T_BITWISE_AND, SL("&") },
{ PHQL_T_BITWISE_OR, SL("|") },
{ PHQL_T_MOD, SL("%%") },
{ PHQL_T_AND, SL("AND") },
{ PHQL_T_OR, SL("OR") },
{ PHQL_T_LIKE, SL("LIKE") },
{ PHQL_T_ILIKE, SL("ILIKE") },
{ PHQL_T_DOT, SL("DOT") },
{ PHQL_T_COLON, SL("COLON") },
{ PHQL_T_COMMA, SL("COMMA") },
{ PHQL_T_EQUALS, SL("EQUALS") },
{ PHQL_T_NOTEQUALS, SL("NOT EQUALS") },
{ PHQL_T_NOT, SL("NOT") },
{ PHQL_T_LESS, SL("<") },
{ PHQL_T_LESSEQUAL, SL("<=") },
{ PHQL_T_GREATER, SL(">") },
{ PHQL_T_GREATEREQUAL, SL(">=") },
{ PHQL_T_PARENTHESES_OPEN, SL("(") },
{ PHQL_T_PARENTHESES_CLOSE, SL(")") },
{ PHQL_T_NPLACEHOLDER, SL("NUMERIC PLACEHOLDER") },
{ PHQL_T_SPLACEHOLDER, SL("STRING PLACEHOLDER") },
{ PHQL_T_UPDATE, SL("UPDATE") },
{ PHQL_T_SET, SL("SET") },
{ PHQL_T_WHERE, SL("WHERE") },
{ PHQL_T_DELETE, SL("DELETE") },
{ PHQL_T_FROM, SL("FROM") },
{ PHQL_T_AS, SL("AS") },
{ PHQL_T_INSERT, SL("INSERT") },
{ PHQL_T_INTO, SL("INTO") },
{ PHQL_T_VALUES, SL("VALUES") },
{ PHQL_T_SELECT, SL("SELECT") },
{ PHQL_T_ORDER, SL("ORDER") },
{ PHQL_T_BY, SL("BY") },
{ PHQL_T_LIMIT, SL("LIMIT") },
{ PHQL_T_OFFSET, SL("OFFSET") },
{ PHQL_T_GROUP, SL("GROUP") },
{ PHQL_T_HAVING, SL("HAVING") },
{ PHQL_T_IN, SL("IN") },
{ PHQL_T_ON, SL("ON") },
{ PHQL_T_INNER, SL("INNER") },
{ PHQL_T_JOIN, SL("JOIN") },
{ PHQL_T_LEFT, SL("LEFT") },
{ PHQL_T_RIGHT, SL("RIGHT") },
{ PHQL_T_IS, SL("IS") },
{ PHQL_T_NULL, SL("NULL") },
{ PHQL_T_NOTIN, SL("NOT IN") },
{ PHQL_T_CROSS, SL("CROSS") },
{ PHQL_T_OUTER, SL("OUTER") },
{ PHQL_T_FULL, SL("FULL") },
{ PHQL_T_ASC, SL("ASC") },
{ PHQL_T_DESC, SL("DESC") },
{ PHQL_T_BETWEEN, SL("BETWEEN") },
{ PHQL_T_DISTINCT, SL("DISTINCT") },
{ PHQL_T_AGAINST, SL("AGAINST") },
{ PHQL_T_CAST, SL("CAST") },
{ PHQL_T_CONVERT, SL("CONVERT") },
{ PHQL_T_USING, SL("USING") },
{ 0, NULL, 0 }
{ SL("INTEGER"), PHQL_T_INTEGER },
{ SL("DOUBLE"), PHQL_T_DOUBLE },
{ SL("STRING"), PHQL_T_STRING },
{ SL("IDENTIFIER"), PHQL_T_IDENTIFIER },
{ SL("MINUS"), PHQL_T_MINUS },
{ SL("+"), PHQL_T_ADD },
{ SL("-"), PHQL_T_SUB },
{ SL("*"), PHQL_T_MUL },
{ SL("/"), PHQL_T_DIV },
{ SL("&"), PHQL_T_BITWISE_AND },
{ SL("|"), PHQL_T_BITWISE_OR },
{ SL("%%"), PHQL_T_MOD },
{ SL("AND"), PHQL_T_AND },
{ SL("OR"), PHQL_T_OR },
{ SL("LIKE"), PHQL_T_LIKE },
{ SL("ILIKE"), PHQL_T_ILIKE },
{ SL("DOT"), PHQL_T_DOT },
{ SL("COLON"), PHQL_T_COLON },
{ SL("COMMA"), PHQL_T_COMMA },
{ SL("EQUALS"), PHQL_T_EQUALS },
{ SL("NOT EQUALS"), PHQL_T_NOTEQUALS },
{ SL("NOT"), PHQL_T_NOT },
{ SL("<"), PHQL_T_LESS },
{ SL("<="), PHQL_T_LESSEQUAL },
{ SL(">"), PHQL_T_GREATER },
{ SL(">="), PHQL_T_GREATEREQUAL },
{ SL("("), PHQL_T_PARENTHESES_OPEN },
{ SL(")"), PHQL_T_PARENTHESES_CLOSE },
{ SL("NUMERIC PLACEHOLDER"), PHQL_T_NPLACEHOLDER },
{ SL("STRING PLACEHOLDER"), PHQL_T_SPLACEHOLDER },
{ SL("UPDATE"), PHQL_T_UPDATE },
{ SL("SET"), PHQL_T_SET },
{ SL("WHERE"), PHQL_T_WHERE },
{ SL("DELETE"), PHQL_T_DELETE },
{ SL("FROM"), PHQL_T_FROM },
{ SL("AS"), PHQL_T_AS },
{ SL("INSERT"), PHQL_T_INSERT },
{ SL("INTO"), PHQL_T_INTO },
{ SL("VALUES"), PHQL_T_VALUES },
{ SL("SELECT"), PHQL_T_SELECT },
{ SL("ORDER"), PHQL_T_ORDER },
{ SL("BY"), PHQL_T_BY },
{ SL("LIMIT"), PHQL_T_LIMIT },
{ SL("OFFSET"), PHQL_T_OFFSET },
{ SL("GROUP"), PHQL_T_GROUP },
{ SL("HAVING"), PHQL_T_HAVING },
{ SL("IN"), PHQL_T_IN },
{ SL("ON"), PHQL_T_ON },
{ SL("INNER"), PHQL_T_INNER },
{ SL("JOIN"), PHQL_T_JOIN },
{ SL("LEFT"), PHQL_T_LEFT },
{ SL("RIGHT"), PHQL_T_RIGHT },
{ SL("IS"), PHQL_T_IS },
{ SL("NULL"), PHQL_T_NULL },
{ SL("NOT IN"), PHQL_T_NOTIN },
{ SL("CROSS"), PHQL_T_CROSS },
{ SL("OUTER"), PHQL_T_OUTER },
{ SL("FULL"), PHQL_T_FULL },
{ SL("ASC"), PHQL_T_ASC },
{ SL("DESC"), PHQL_T_DESC },
{ SL("BETWEEN"), PHQL_T_BETWEEN },
{ SL("DISTINCT"), PHQL_T_DISTINCT },
{ SL("AGAINST"), PHQL_T_AGAINST },
{ SL("CAST"), PHQL_T_CAST },
{ SL("CONVERT"), PHQL_T_CONVERT },
{ SL("USING"), PHQL_T_USING },
{ NULL, 0, 0 }
};

static void *phql_wrapper_alloc(size_t bytes){
Expand Down Expand Up @@ -566,4 +566,4 @@ int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length
efree(state);

return status;
}
}
Loading

0 comments on commit c0378c0

Please sign in to comment.