summaryrefslogtreecommitdiffstats
path: root/input.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-10-03 00:13:46 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-10-03 00:13:46 +0000
commitef91aac6887e82b77ca3dff8bcffaffab0a8ec08 (patch)
tree6f6db2314ca66fe045b4df3aec7f60464f2bece7 /input.c
parenta6d3594d395a61cfab97a69ebcf85bff71875f2f (diff)
Add profiling. Also some trivial optimisations to skip memcpying.
Diffstat (limited to 'input.c')
-rw-r--r--input.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/input.c b/input.c
index b82eae2c..3f3d7f9c 100644
--- a/input.c
+++ b/input.c
@@ -1,4 +1,4 @@
-/* $Id: input.c,v 1.16 2007-10-01 17:37:41 nicm Exp $ */
+/* $Id: input.c,v 1.17 2007-10-03 00:13:46 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1107,13 +1107,18 @@ input_store_two(struct buffer *b, u_char code, uint16_t ua, uint16_t ub)
void
input_store8(struct buffer *b, uint8_t n)
{
- buffer_write(b, &n, sizeof n);
+ buffer_ensure(b, 1);
+ BUFFER_IN(b)[0] = n;
+ buffer_add(b, 1);
}
void
input_store16(struct buffer *b, uint16_t n)
{
- buffer_write(b, &n, sizeof n);
+ buffer_ensure(b, 2);
+ BUFFER_IN(b)[0] = n & 0xff;
+ BUFFER_IN(b)[1] = n >> 8;
+ buffer_add(b, 2);
}
uint8_t
@@ -1121,7 +1126,8 @@ input_extract8(struct buffer *b)
{
uint8_t n;
- buffer_read(b, &n, sizeof n);
+ n = BUFFER_OUT(b)[0];
+ buffer_remove(b, 1);
return (n);
}
@@ -1130,6 +1136,7 @@ input_extract16(struct buffer *b)
{
uint16_t n;
- buffer_read(b, &n, sizeof n);
+ n = BUFFER_OUT(b)[0] | (BUFFER_OUT(b)[1] << 8);
+ buffer_remove(b, 2);
return (n);
}