Skip to content

Commit fd4fe9b

Browse files
Merge MR 'Reduce RAM usage in various structures'
As I understand in BIH_UNORDERED only children array is used, while front, back, min and max are never written. Opposite true for other node types. On side note sizes should be explicitly added to ints. See https://gitlab.com/xonotic/darkplaces/-/merge_requests/149 Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 parents 1f7a765 + cfe8e9b commit fd4fe9b

File tree

3 files changed

+255
-59
lines changed

3 files changed

+255
-59
lines changed

bih.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ typedef struct bih_node_s
3939
// TODO: move bounds data to parent node and remove it from leafs?
4040
float mins[3];
4141
float maxs[3];
42-
// node indexes of children (always > this node's index)
43-
int front;
44-
int back;
45-
// interval of children
46-
float frontmin; // children[0]
47-
float backmax; // children[1]
48-
// BIH_UNORDERED uses this for a list of leafindex (all >= 0), -1 = end of list
49-
int children[BIH_MAXUNORDEREDCHILDREN];
42+
union {
43+
struct{
44+
// node indexes of children (always > this node's index)
45+
int front;
46+
int back;
47+
// interval of children
48+
float frontmin; // children[0]
49+
float backmax; // children[1]
50+
};
51+
// BIH_UNORDERED uses this for a list of leafindex (all >= 0), -1 = end of list
52+
int children[BIH_MAXUNORDEREDCHILDREN];
53+
};
5054
}
5155
bih_node_t;
5256

com_crc16.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3636
#define CRC_INIT_VALUE 0xffff
3737
#define CRC_XOR_VALUE 0x0000
3838

39-
static unsigned short crctable[256] =
39+
static const u16 crctable[256] =
4040
{
4141
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
4242
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
@@ -89,7 +89,7 @@ unsigned short CRC_Block_CaseInsensitive(const unsigned char *data, size_t size)
8989
}
9090

9191
// QuakeWorld
92-
static unsigned char chktbl[1024 + 4] =
92+
static const u8 chktbl[1024 + 4] =
9393
{
9494
0x78,0xd2,0x94,0xe3,0x41,0xec,0xd6,0xd5,0xcb,0xfc,0xdb,0x8a,0x4b,0xcc,0x85,0x01,
9595
0x23,0xd2,0xe5,0xf2,0x29,0xa7,0x45,0x94,0x4a,0x62,0xe3,0xa5,0x6f,0x3f,0xe1,0x7a,
@@ -131,7 +131,7 @@ static unsigned char chktbl[1024 + 4] =
131131
// QuakeWorld
132132
unsigned char COM_BlockSequenceCRCByteQW(unsigned char *base, int length, int sequence)
133133
{
134-
unsigned char *p;
134+
const unsigned char *p;
135135
unsigned char chkb[60 + 4];
136136

137137
p = chktbl + (sequence % (sizeof(chktbl) - 8));

0 commit comments

Comments
 (0)