Skip to content

${options.prefix}_s struct size #35

@fanatid

Description

@fanatid

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions