From 623df388782dcfe70f4f147cb24197e535f9c89b Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 21 Jan 2026 15:48:25 +0100 Subject: pkg/codesearch: reduce memory consumption a bit more Use uint32 instead of int for line numbers (2G lines should be enough for everyone). Reorder fields to remove unnecessary paddings. --- pkg/codesearch/testdata/mm/refs.c.json | 4 ++-- pkg/codesearch/testdata/refs.c.json | 40 +++++++++++++++++----------------- pkg/codesearch/testdata/source0.c.json | 40 +++++++++++++++++----------------- pkg/codesearch/testdata/source1.c.json | 2 +- pkg/codesearch/testdata/source2.c.json | 2 +- 5 files changed, 44 insertions(+), 44 deletions(-) (limited to 'pkg/codesearch/testdata') diff --git a/pkg/codesearch/testdata/mm/refs.c.json b/pkg/codesearch/testdata/mm/refs.c.json index 09ac87f98..50aa676be 100644 --- a/pkg/codesearch/testdata/mm/refs.c.json +++ b/pkg/codesearch/testdata/mm/refs.c.json @@ -1,9 +1,9 @@ { "definitions": [ { - "kind": "function", "name": "ref_in_mm", "type": "void ()", + "kind": "function", "body": { "file": "mm/refs.c", "start_line": 3, @@ -12,9 +12,9 @@ "comment": {}, "refs": [ { + "name": "refs2", "kind": "calls", "entity_kind": "function", - "name": "refs2", "line": 5 } ] diff --git a/pkg/codesearch/testdata/refs.c.json b/pkg/codesearch/testdata/refs.c.json index 289ce7c30..d8a1034e2 100644 --- a/pkg/codesearch/testdata/refs.c.json +++ b/pkg/codesearch/testdata/refs.c.json @@ -1,9 +1,9 @@ { "definitions": [ { - "kind": "function", "name": "long_func_with_ref", "type": "void ()", + "kind": "function", "body": { "file": "refs.c", "start_line": 23, @@ -12,77 +12,77 @@ "comment": {}, "refs": [ { + "name": "refs0", "kind": "calls", "entity_kind": "function", - "name": "refs0", "line": 25 }, { + "name": "refs1", "kind": "calls", "entity_kind": "function", - "name": "refs1", "line": 26 }, { + "name": "refs0", "kind": "calls", "entity_kind": "function", - "name": "refs0", "line": 27 }, { + "name": "refs1", "kind": "calls", "entity_kind": "function", - "name": "refs1", "line": 28 }, { + "name": "refs2", "kind": "calls", "entity_kind": "function", - "name": "refs2", "line": 29 }, { + "name": "refs1", "kind": "takes-address-of", "entity_kind": "function", - "name": "refs1", "line": 29 }, { + "name": "refs0", "kind": "calls", "entity_kind": "function", - "name": "refs0", "line": 29 }, { + "name": "refs0", "kind": "calls", "entity_kind": "function", - "name": "refs0", "line": 30 }, { + "name": "refs1", "kind": "calls", "entity_kind": "function", - "name": "refs1", "line": 31 }, { + "name": "refs0", "kind": "calls", "entity_kind": "function", - "name": "refs0", "line": 32 }, { + "name": "refs1", "kind": "calls", "entity_kind": "function", - "name": "refs1", "line": 33 } ] }, { - "kind": "function", "name": "refs0", "type": "int ()", + "kind": "function", "body": { "file": "refs.c", "start_line": 4, @@ -95,9 +95,9 @@ } }, { - "kind": "function", "name": "refs1", "type": "void ()", + "kind": "function", "body": { "file": "refs.c", "start_line": 9, @@ -106,9 +106,9 @@ "comment": {} }, { - "kind": "function", "name": "refs2", "type": "void (void (*)(), int)", + "kind": "function", "body": { "file": "refs.c", "start_line": 13, @@ -117,9 +117,9 @@ "comment": {} }, { - "kind": "function", "name": "refs3", "type": "void ()", + "kind": "function", "body": { "file": "refs.c", "start_line": 17, @@ -128,27 +128,27 @@ "comment": {}, "refs": [ { + "name": "refs2", "kind": "calls", "entity_kind": "function", - "name": "refs2", "line": 19 }, { + "name": "refs1", "kind": "takes-address-of", "entity_kind": "function", - "name": "refs1", "line": 19 }, { + "name": "refs0", "kind": "calls", "entity_kind": "function", - "name": "refs0", "line": 19 }, { + "name": "refs2", "kind": "takes-address-of", "entity_kind": "function", - "name": "refs2", "line": 20 } ] diff --git a/pkg/codesearch/testdata/source0.c.json b/pkg/codesearch/testdata/source0.c.json index 1732d7c97..c2c2de3e4 100644 --- a/pkg/codesearch/testdata/source0.c.json +++ b/pkg/codesearch/testdata/source0.c.json @@ -1,8 +1,8 @@ { "definitions": [ { - "kind": "enum", "name": "some_enum", + "kind": "enum", "body": { "file": "source0.h", "start_line": 45, @@ -11,9 +11,9 @@ "comment": {} }, { - "kind": "function", "name": "close", "type": "int ()", + "kind": "function", "body": { "file": "source0.c", "start_line": 19, @@ -22,9 +22,9 @@ "comment": {} }, { - "kind": "function", "name": "func_accepting_a_struct", "type": "int (struct some_struct *)", + "kind": "function", "body": { "file": "source0.c", "start_line": 29, @@ -33,35 +33,35 @@ "comment": {}, "refs": [ { + "name": "some_struct", "kind": "uses", "entity_kind": "struct", - "name": "some_struct", "line": 29 }, { + "name": "some_struct_t", "kind": "uses", "entity_kind": "typedef", - "name": "some_struct_t", "line": 31 }, { + "name": "some_struct", "kind": "uses", "entity_kind": "struct", - "name": "some_struct", "line": 31 }, { + "name": "some_union", "kind": "uses", "entity_kind": "union", - "name": "some_union", "line": 32 } ] }, { - "kind": "function", "name": "func_in_header", "type": "int ()", + "kind": "function", "is_static": true, "body": { "file": "source0.h", @@ -71,9 +71,9 @@ "comment": {} }, { - "kind": "function", "name": "function_with_comment_in_header", "type": "void ()", + "kind": "function", "body": { "file": "source0.c", "start_line": 24, @@ -82,17 +82,17 @@ "comment": {}, "refs": [ { + "name": "same_name_in_several_files", "kind": "calls", "entity_kind": "function", - "name": "same_name_in_several_files", "line": 26 } ] }, { - "kind": "function", "name": "open", "type": "int ()", + "kind": "function", "body": { "file": "source0.c", "start_line": 11, @@ -105,8 +105,8 @@ } }, { - "kind": "struct", "name": "another_struct", + "kind": "struct", "body": { "file": "source0.h", "start_line": 36, @@ -115,8 +115,8 @@ "comment": {} }, { - "kind": "struct", "name": "some_struct", + "kind": "struct", "body": { "file": "source0.h", "start_line": 17, @@ -125,8 +125,8 @@ "comment": {} }, { - "kind": "struct", "name": "some_struct_with_a_comment", + "kind": "struct", "body": { "file": "source0.h", "start_line": 24, @@ -139,8 +139,8 @@ } }, { - "kind": "struct", "name": "struct_in_c_file", + "kind": "struct", "body": { "file": "source0.c", "start_line": 6, @@ -149,8 +149,8 @@ "comment": {} }, { - "kind": "typedef", "name": "another_struct_t", + "kind": "typedef", "body": { "file": "source0.h", "start_line": 36, @@ -159,8 +159,8 @@ "comment": {} }, { - "kind": "typedef", "name": "some_enum_t", + "kind": "typedef", "body": { "file": "source0.h", "start_line": 50, @@ -169,8 +169,8 @@ "comment": {} }, { - "kind": "typedef", "name": "some_struct_t", + "kind": "typedef", "body": { "file": "source0.h", "start_line": 22, @@ -179,8 +179,8 @@ "comment": {} }, { - "kind": "typedef", "name": "typedefed_struct_t", + "kind": "typedef", "body": { "file": "source0.h", "start_line": 32, @@ -189,8 +189,8 @@ "comment": {} }, { - "kind": "union", "name": "some_union", + "kind": "union", "body": { "file": "source0.h", "start_line": 40, diff --git a/pkg/codesearch/testdata/source1.c.json b/pkg/codesearch/testdata/source1.c.json index 72278a191..9a90d789f 100644 --- a/pkg/codesearch/testdata/source1.c.json +++ b/pkg/codesearch/testdata/source1.c.json @@ -1,9 +1,9 @@ { "definitions": [ { - "kind": "function", "name": "same_name_in_several_files", "type": "void ()", + "kind": "function", "is_static": true, "body": { "file": "source1.c", diff --git a/pkg/codesearch/testdata/source2.c.json b/pkg/codesearch/testdata/source2.c.json index 4407152db..5e75950c0 100644 --- a/pkg/codesearch/testdata/source2.c.json +++ b/pkg/codesearch/testdata/source2.c.json @@ -1,9 +1,9 @@ { "definitions": [ { - "kind": "function", "name": "same_name_in_several_files", "type": "void ()", + "kind": "function", "body": { "file": "source2.c", "start_line": 4, -- cgit mrf-deployment