${options.prefix}_s struct size
fanatid opened this issue · 1 comments
fanatid commented
If int32_t index;
from https://github.com/nodejs/llparse/blob/v6.2.1/src/compiler/header-builder.ts#L31 will be moved to next int32_t
https://github.com/nodejs/llparse/blob/v6.2.1/src/compiler/header-builder.ts#L40 this will save 8 bytes on x64.
Does it makes sense to change definition order?
llhttp (96 => 88):
#include <inttypes.h>
#include <stdio.h>
struct llhttp__internal_s {
int32_t _index;
void* _span_pos0;
void* _span_cb0;
int32_t error;
const char* reason;
const char* error_pos;
void* data;
void* _current;
uint64_t content_length;
uint8_t type;
uint8_t method;
uint8_t http_major;
uint8_t http_minor;
uint8_t header_state;
uint16_t flags;
uint8_t upgrade;
uint16_t status_code;
uint8_t finish;
void* settings;
};
struct llhttp__internal_s2 {
void* _span_pos0;
void* _span_cb0;
int32_t _index;
int32_t error;
const char* reason;
const char* error_pos;
void* data;
void* _current;
uint64_t content_length;
uint8_t type;
uint8_t method;
uint8_t http_major;
uint8_t http_minor;
uint8_t header_state;
uint16_t flags;
uint8_t upgrade;
uint16_t status_code;
uint8_t finish;
void* settings;
};
int main() {
printf("%ld %ld\n", sizeof(struct llhttp__internal_s), sizeof(struct llhttp__internal_s2));
return 0;
}