Skip to content

Commit ec8707e

Browse files
committed
Make encode() static inline.
1 parent bce067c commit ec8707e

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

codes.c

-14
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747

4848
#include <stdio.h>
4949
#include <stdint.h>
50-
#include <string.h>
5150

5251
#include "bitmath.h"
5352
#include "codes.h"
@@ -63,19 +62,6 @@ code_t codes[] = {
6362
{.name = NULL, .n = 0, .k = 0, .file = NULL},
6463
};
6564

66-
67-
void encode(const code_t *code, void *c, const void *word)
68-
{
69-
bitset_zero(c, code->n);
70-
71-
for (size_t i = 0; i < code->k; ++i) {
72-
if (getbit(word, i)) {
73-
bitxor(c, row(code->_G, i), code->n);
74-
}
75-
}
76-
}
77-
78-
7965
// XXX. return error.
8066
static void load_G(code_t *code)
8167
{

codes.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include <stdint.h>
3+
#include <string.h>
34

45
#include "bitmath.h"
56

@@ -16,7 +17,18 @@ typedef struct code {
1617
} code_t;
1718

1819

19-
void encode(const code_t* code, void *c, const void *word);
20+
static inline
21+
void encode(const code_t *code, void *c, const void *word)
22+
{
23+
bitset_zero(c, code->n);
24+
25+
for (size_t i = 0; i < code->k; ++i) {
26+
if (getbit(word, i)) {
27+
bitxor(c, row(code->_G, i), code->n);
28+
}
29+
}
30+
}
31+
2032
code_t *load_codestr(const char *alias);
2133
void unload_code(code_t * code);
2234

0 commit comments

Comments
 (0)