summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-05-02 12:39:02 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-05-02 12:39:02 +0200
commit33edd4a542232582368f85203e0640c5f8123e76 (patch)
treedf0c335aabf52b88668805be328b04134ae64297
parent4be69efe315f2c510b886ce0039df8d52695cae0 (diff)
downloadipecamera-33edd4a542232582368f85203e0640c5f8123e76.tar.gz
ipecamera-33edd4a542232582368f85203e0640c5f8123e76.tar.bz2
ipecamera-33edd4a542232582368f85203e0640c5f8123e76.tar.xz
ipecamera-33edd4a542232582368f85203e0640c5f8123e76.zip
A bit faster datacpy
-rw-r--r--tools.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/tools.c b/tools.c
index 6076f18..1ff3177 100644
--- a/tools.c
+++ b/tools.c
@@ -197,19 +197,26 @@ void *pcilib_datacpy32(void * dst, void const * src, uint8_t size, size_t n, pci
uint32_t const * plSrc = (uint32_t const *) src;
int swap = 0;
-
- if (endianess) swap = (endianess == PCILIB_BIG_ENDIAN)?(ntohs(1)!=1):(ntohs(1)==1);
-
- assert(size == 4); // only 32 bit at the moment
- while (n > 0) {
- if (swap) *plDst = ntohl(*plSrc);
- else *plDst = *plSrc;
+ if (endianess)
+ swap = (endianess == PCILIB_BIG_ENDIAN)?(ntohs(1)!=1):(ntohs(1)==1);
- ++plSrc;
- ++plDst;
+ assert(size == 4); // only 32 bit at the moment
- --n;
+ if (swap) {
+ while (n > 0) {
+ *plDst = ntohl(*plSrc);
+ ++plSrc;
+ ++plDst;
+ --n;
+ }
+ } else {
+ while (n > 0) {
+ *plDst = *plSrc;
+ ++plSrc;
+ ++plDst;
+ --n;
+ }
}
}