diff options
| author | batleram <batleram@gmail.com> | 2026-10-24 17:59:43 -0400 |
|---|---|---|
| committer | batleram <batleram@gmail.com> | 2026-10-24 17:59:43 -0400 |
| commit | f692f2b7c3a47f156aff5a457bbd9bddb0619249 (patch) | |
| tree | ee62e47ee0db77291765ca2cc225dd6e0569d377 /calc.c | |
| parent | fc1252710f8064bb144677e17a598933b4c68d13 (diff) | |
cleanup lut ~800ms
Diffstat (limited to 'calc.c')
| -rw-r--r-- | calc.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -32,20 +32,20 @@ uint32_t subnetmask_for_netspace(unsigned int desired_netspace) { void write_ip(char **chunk_ptr, uint32_t ip) { // local ptr so we don't have to deref every time char *ptr = *chunk_ptr; - LutEntry e = {.bits = itoa_lut[(ip >> 24) & 0xff]}; - WRITE_STR(ptr, e.fields.chars, e.fields.len) + LutEntry e = itoa_lut[(ip >> 24) & 0xff]; + WRITE_STR(ptr, e.chars, e.len) ptr[0] = '.'; ptr += 1; - e.bits = itoa_lut[(ip >> 16) & 0xff]; - WRITE_STR(ptr, e.fields.chars, e.fields.len) + e = itoa_lut[(ip >> 16) & 0xff]; + WRITE_STR(ptr, e.chars, e.len) ptr[0] = '.'; ptr += 1; - e.bits = itoa_lut[(ip >> 8) & 0xff]; - WRITE_STR(ptr, e.fields.chars, e.fields.len) + e = itoa_lut[(ip >> 8) & 0xff]; + WRITE_STR(ptr, e.chars, e.len) ptr[0] = '.'; ptr += 1; - e.bits = itoa_lut[ip & 0xff]; - WRITE_STR(ptr, e.fields.chars, e.fields.len) + e = itoa_lut[ip & 0xff]; + WRITE_STR(ptr, e.chars, e.len) *chunk_ptr = ptr; } @@ -106,8 +106,8 @@ int main(int argc, char** argv) { write_ip(&chunk_ptr, broadcast); WRITE_STR(chunk_ptr, "\",\n", 3) WRITE_STR(chunk_ptr, "\t\t\"Nbr\": \"", 10) - LutEntry e = {.bits = itoa_lut[ips_per_subnet - 2]}; - WRITE_STR(chunk_ptr, e.fields.chars, e.fields.len); + LutEntry e = itoa_lut[ips_per_subnet - 2]; + WRITE_STR(chunk_ptr, e.chars, e.len); if (i+1 == req.count) { WRITE_STR(chunk_ptr, "\"\n\t}\n", 5) }else { |
