Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2013-04-09 17:06:12 -0400
committerEugene Tarassov2013-04-09 17:06:12 -0400
commit0c0772c2fb2eeabb179286b5024db482cf793193 (patch)
tree25d4cf8f84ea64489f427a8c5a3879be37128e63
parent6aa3c5990924d04ff9ae4f36b0b231ddbe96a755 (diff)
downloadorg.eclipse.tcf.agent-0c0772c2fb2eeabb179286b5024db482cf793193.tar.gz
org.eclipse.tcf.agent-0c0772c2fb2eeabb179286b5024db482cf793193.tar.xz
org.eclipse.tcf.agent-0c0772c2fb2eeabb179286b5024db482cf793193.zip
TCF Agent: faster ByteArrayInputStream
-rw-r--r--agent/tcf/framework/streams.c14
-rw-r--r--agent/tcf/framework/streams.h4
2 files changed, 8 insertions, 10 deletions
diff --git a/agent/tcf/framework/streams.c b/agent/tcf/framework/streams.c
index 74aaac20..3ee242ce 100644
--- a/agent/tcf/framework/streams.c
+++ b/agent/tcf/framework/streams.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -141,22 +141,22 @@ void get_byte_array_output_stream_data(ByteArrayOutputStream * buf, char ** data
static int read_byte_array_input_stream(InputStream * inp) {
ByteArrayInputStream * buf = (ByteArrayInputStream *)((char *)inp - offsetof(ByteArrayInputStream, inp));
- if (buf->pos >= buf->max) return MARKER_EOS;
- return ((unsigned char *)buf->buf)[buf->pos++];
+ if (buf->inp.cur >= buf->inp.end) return MARKER_EOS;
+ return *buf->inp.cur++;
}
static int peek_byte_array_input_stream(InputStream * inp) {
ByteArrayInputStream * buf = (ByteArrayInputStream *)((char *)inp - offsetof(ByteArrayInputStream, inp));
- if (buf->pos >= buf->max) return MARKER_EOS;
- return ((unsigned char *)buf->buf)[buf->pos];
+ if (buf->inp.cur >= buf->inp.end) return MARKER_EOS;
+ return *buf->inp.cur;
}
InputStream * create_byte_array_input_stream(ByteArrayInputStream * buf, const char * data, size_t size) {
memset(buf, 0, sizeof(ByteArrayInputStream));
buf->inp.read = read_byte_array_input_stream;
buf->inp.peek = peek_byte_array_input_stream;
- buf->buf = data;
- buf->max = size;
+ buf->inp.cur = (unsigned char *)data;
+ buf->inp.end = (unsigned char *)data + size;
return &buf->inp;
}
diff --git a/agent/tcf/framework/streams.h b/agent/tcf/framework/streams.h
index 27a05614..ff77bfc0 100644
--- a/agent/tcf/framework/streams.h
+++ b/agent/tcf/framework/streams.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -102,8 +102,6 @@ extern void get_byte_array_output_stream_data(ByteArrayOutputStream * buf, char
typedef struct ByteArrayInputStream {
InputStream inp;
const char * buf;
- size_t pos;
- size_t max;
} ByteArrayInputStream;
extern InputStream * create_byte_array_input_stream(ByteArrayInputStream * buf, const char * data, size_t size);

Back to the top