summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-08 13:49:11 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-08 13:49:11 +0200
commit94e774a8bd2891f36885ae710efd42caebd855ed (patch)
tree883147e1bf5dc8feba5d142b8ffcde8e7e0676f6 /fitz
parenta1b5f023ccebd339e9a74ef7f3bcc94c0c74d3e0 (diff)
downloadmupdf-94e774a8bd2891f36885ae710efd42caebd855ed.tar.xz
Remove inline keyword where it is not strictly necessary for performance.
Also put the function on the same line for inline functions, so they stick out and are easy to find with grep.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/filt_basic.c15
-rw-r--r--fitz/filt_faxd.c49
-rw-r--r--fitz/filt_predict.c24
-rw-r--r--fitz/obj_dict.c19
4 files changed, 35 insertions, 72 deletions
diff --git a/fitz/filt_basic.c b/fitz/filt_basic.c
index 391f06ab..feb13076 100644
--- a/fitz/filt_basic.c
+++ b/fitz/filt_basic.c
@@ -75,14 +75,11 @@ static inline int ishex(int a)
(a >= '0' && a <= '9');
}
-static inline int from_hex(int a)
+static inline int unhex(int a)
{
- if (a >= 'A' && a <= 'F')
- return a - 'A' + 0xA;
- if (a >= 'a' && a <= 'f')
- return a - 'a' + 0xA;
- if (a >= '0' && a <= '9')
- return a - '0';
+ if (a >= 'A' && a <= 'F') return a - 'A' + 0xA;
+ if (a >= 'a' && a <= 'f') return a - 'a' + 0xA;
+ if (a >= '0' && a <= '9') return a - '0';
return 0;
}
@@ -109,12 +106,12 @@ read_ahxd(fz_stream *stm, unsigned char *buf, int len)
{
if (!odd)
{
- a = from_hex(c);
+ a = unhex(c);
odd = 1;
}
else
{
- b = from_hex(c);
+ b = unhex(c);
*p++ = (a << 4) | b;
odd = 0;
}
diff --git a/fitz/filt_faxd.c b/fitz/filt_faxd.c
index 97076f89..dcf56cf3 100644
--- a/fitz/filt_faxd.c
+++ b/fitz/filt_faxd.c
@@ -170,33 +170,12 @@ const cfd_node cf_uncompressed_decode[] = {
/* bit magic */
-static inline void
-print_bits(FILE *f, int code, int nbits)
-{
- int n, b;
- for (n = nbits - 1; n >= 0; n--)
- {
- b = (code >> n) & 1;
- fprintf(f, "%c", b ? '1' : '0');
- }
-}
-
-static inline int
-getbit(const unsigned char *buf, int x)
+static inline int getbit(const unsigned char *buf, int x)
{
return ( buf[x >> 3] >> ( 7 - (x & 7) ) ) & 1;
}
-static inline void
-print_line(FILE *f, unsigned char *line, int w)
-{
- int i;
- for (i = 0; i < w; i++)
- fprintf(f, "%c", getbit(line, i) ? '#' : '.');
- fprintf(f, "\n");
-}
-
-static inline int
+static int
find_changing(const unsigned char *line, int x, int w)
{
int a, b;
@@ -226,7 +205,7 @@ find_changing(const unsigned char *line, int x, int w)
return x;
}
-static inline int
+static int
find_changing_color(const unsigned char *line, int x, int w, int color)
{
if (!line)
@@ -248,8 +227,7 @@ static const unsigned char rm[8] = {
0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE
};
-static inline void
-setbits(unsigned char *line, int x0, int x1)
+static inline void setbits(unsigned char *line, int x0, int x1)
{
int a0, a1, b0, b1, a;
@@ -311,14 +289,13 @@ struct fz_faxd_s
unsigned char *rp, *wp;
};
-static inline void
-eat_bits(fz_faxd *fax, int nbits)
+static inline void eat_bits(fz_faxd *fax, int nbits)
{
fax->word <<= nbits;
fax->bidx += nbits;
}
-static inline int
+static int
fill_bits(fz_faxd *fax)
{
while (fax->bidx >= 8)
@@ -332,8 +309,8 @@ fill_bits(fz_faxd *fax)
return 0;
}
-static inline int
-getcode(fz_faxd *fax, const cfd_node *table, int initialbits)
+static int
+get_code(fz_faxd *fax, const cfd_node *table, int initialbits)
{
unsigned int word = fax->word;
int tidx = word >> (32 - initialbits);
@@ -363,9 +340,9 @@ dec1d(fz_faxd *fax)
fax->a = 0;
if (fax->c)
- code = getcode(fax, cf_black_decode, cfd_black_initial_bits);
+ code = get_code(fax, cf_black_decode, cfd_black_initial_bits);
else
- code = getcode(fax, cf_white_decode, cfd_white_initial_bits);
+ code = get_code(fax, cf_white_decode, cfd_white_initial_bits);
if (code == UNCOMPRESSED)
return fz_throw("uncompressed data in faxd");
@@ -404,9 +381,9 @@ dec2d(fz_faxd *fax)
fax->a = 0;
if (fax->c)
- code = getcode(fax, cf_black_decode, cfd_black_initial_bits);
+ code = get_code(fax, cf_black_decode, cfd_black_initial_bits);
else
- code = getcode(fax, cf_white_decode, cfd_white_initial_bits);
+ code = get_code(fax, cf_white_decode, cfd_white_initial_bits);
if (code == UNCOMPRESSED)
return fz_throw("uncompressed data in faxd");
@@ -434,7 +411,7 @@ dec2d(fz_faxd *fax)
return fz_okay;
}
- code = getcode(fax, cf_2d_decode, cfd_2d_initial_bits);
+ code = get_code(fax, cf_2d_decode, cfd_2d_initial_bits);
switch (code)
{
diff --git a/fitz/filt_predict.c b/fitz/filt_predict.c
index 1501fc09..94f2718a 100644
--- a/fitz/filt_predict.c
+++ b/fitz/filt_predict.c
@@ -23,33 +23,31 @@ struct fz_predict_s
unsigned char *rp, *wp;
};
-static inline int
-getcomponent(unsigned char *buf, int x, int bpc)
+static inline int getcomponent(unsigned char *line, int x, int bpc)
{
switch (bpc)
{
- case 1: return buf[x / 8] >> (7 - (x % 8)) & 0x01;
- case 2: return buf[x / 4] >> ((3 - (x % 4)) * 2) & 0x03;
- case 4: return buf[x / 2] >> ((1 - (x % 2)) * 4) & 0x0f;
- case 8: return buf[x];
+ case 1: return (line[x >> 3] >> ( 7 - (x & 7) ) ) & 1;
+ case 2: return (line[x >> 2] >> ( ( 3 - (x & 3) ) << 1 ) ) & 3;
+ case 4: return (line[x >> 1] >> ( ( 1 - (x & 1) ) << 2 ) ) & 15;
+ case 8: return line[x];
}
return 0;
}
-static inline void
-putcomponent(unsigned char *buf, int x, int bpc, int value)
+
+static inline void putcomponent(unsigned char *buf, int x, int bpc, int value)
{
switch (bpc)
{
- case 1: buf[x / 8] |= value << (7 - (x % 8)); break;
- case 2: buf[x / 4] |= value << ((3 - (x % 4)) * 2); break;
- case 4: buf[x / 2] |= value << ((1 - (x % 2)) * 4); break;
+ case 1: buf[x >> 3] |= value << (7 - (x & 7)); break;
+ case 2: buf[x >> 2] |= value << ((3 - (x & 3)) << 1); break;
+ case 4: buf[x >> 1] |= value << ((1 - (x & 1)) << 2); break;
case 8: buf[x] = value; break;
}
}
-static inline int
-paeth(int a, int b, int c)
+static inline int paeth(int a, int b, int c)
{
/* The definitions of ac and bc are correct, not a typo. */
int ac = b - c, bc = a - c, abcc = ac + bc;
diff --git a/fitz/obj_dict.c b/fitz/obj_dict.c
index 6f3ba9da..d165f46d 100644
--- a/fitz/obj_dict.c
+++ b/fitz/obj_dict.c
@@ -6,16 +6,7 @@ static int keyvalcmp(const void *ap, const void *bp)
{
const fz_keyval *a = ap;
const fz_keyval *b = bp;
- if (fz_is_name(a->k) && fz_is_name(b->k))
- return strcmp(fz_to_name(a->k), fz_to_name(b->k));
- return -1;
-}
-
-static inline int keystrcmp(fz_obj *key, char *s)
-{
- if (fz_is_name(key))
- return strcmp(fz_to_name(key), s);
- return -1;
+ return strcmp(fz_to_name(a->k), fz_to_name(b->k));
}
fz_obj *
@@ -95,7 +86,7 @@ fz_dict_get_val(fz_obj *obj, int i)
return obj->u.d.items[i].v;
}
-static inline int
+static int
fz_dict_finds(fz_obj *obj, char *key)
{
if (obj->u.d.sorted)
@@ -105,7 +96,7 @@ fz_dict_finds(fz_obj *obj, char *key)
while (l <= r)
{
int m = (l + r) >> 1;
- int c = -keystrcmp(obj->u.d.items[m].k, key);
+ int c = -strcmp(fz_to_name(obj->u.d.items[m].k), key);
if (c < 0)
r = m - 1;
else if (c > 0)
@@ -119,7 +110,7 @@ fz_dict_finds(fz_obj *obj, char *key)
{
int i;
for (i = 0; i < obj->u.d.len; i++)
- if (keystrcmp(obj->u.d.items[i].k, key) == 0)
+ if (strcmp(fz_to_name(obj->u.d.items[i].k), key) == 0)
return i;
}
@@ -210,7 +201,7 @@ fz_dict_put(fz_obj *obj, fz_obj *key, fz_obj *val)
/* borked! */
if (obj->u.d.len)
- if (keystrcmp(obj->u.d.items[obj->u.d.len - 1].k, s) > 0)
+ if (strcmp(fz_to_name(obj->u.d.items[obj->u.d.len - 1].k), s) > 0)
obj->u.d.sorted = 0;
obj->u.d.items[obj->u.d.len].k = fz_keep_obj(key);