ast: pack the ParseCommon struct

This shows a measurable improvement in memory and performance for free,
on 64bit at least. Packing is (or should be) safe in this case.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2013-12-14 17:39:11 +02:00
parent 9a3c115be0
commit 1e6e5669c6
2 changed files with 10 additions and 2 deletions

View File

@ -206,4 +206,10 @@ unmap_file(const char *str, size_t size);
# define ATTR_NULL_SENTINEL
#endif /* GNUC >= 4 */
#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 295)
#define ATTR_PACKED __attribute__((__packed__))
#else
#define ATTR_PACKED
#endif
#endif /* UTILS_H */

View File

@ -143,9 +143,11 @@ expr_op_type_to_string(enum expr_op_type type);
const char *
expr_value_type_to_string(enum expr_value_type type);
typedef struct _ParseCommon {
enum stmt_type type;
/* This struct contains fields common to all other AST nodes. It is only
* ever embedded in other structs, so save some memory by packing it. */
typedef struct ATTR_PACKED _ParseCommon {
struct _ParseCommon *next;
enum stmt_type type;
} ParseCommon;
typedef struct _IncludeStmt {