Don't use int casting hack when comparion entity references
Now using plain old byte-for-byte comparisons. Performance-wise the
difference is acceptable, but it does add more than 100 bytes to the
library. :-(
diff --git a/yxml.c b/yxml.c
index 17c2dd2..214d6eb 100644
--- a/yxml.c
+++ b/yxml.c
@@ -298,17 +298,15 @@
if(*r)
ch = 0;
} else {
- uint64_t ri;
- memcpy(&ri, r, 8);
- if(ri == *((uint64_t *)"lt\0\0\0\0\0"))
+ if(r[0] == 'l' && r[1] == 't' && !r[2])
ch = '<';
- else if(ri == *((uint64_t *)"gt\0\0\0\0\0"))
+ else if(r[0] == 'g' && r[1] == 't' && !r[2])
ch = '>';
- else if(ri == *((uint64_t *)"amp\0\0\0\0"))
+ else if(r[0] == 'a' && r[1] == 'm' && r[2] == 'p' && !r[3])
ch = '&';
- else if(ri == *((uint64_t *)"apos\0\0\0"))
+ else if(r[0] == 'a' && r[1] == 'p' && r[2] == 'o' && r[3] == 's' && !r[4])
ch = '\'';
- else if(ri == *((uint64_t *)"quot\0\0\0"))
+ else if(r[0] == 'q' && r[1] == 'u' && r[2] == 'o' && r[3] == 't' && !r[4])
ch = '"';
}
diff --git a/yxml.c.in b/yxml.c.in
index dfc5b9d..21f9c38 100644
--- a/yxml.c.in
+++ b/yxml.c.in
@@ -234,17 +234,15 @@
if(*r)
ch = 0;
} else {
- uint64_t ri;
- memcpy(&ri, r, 8);
- if(ri == *((uint64_t *)"lt\0\0\0\0\0"))
+ if(r[0] == 'l' && r[1] == 't' && !r[2])
ch = '<';
- else if(ri == *((uint64_t *)"gt\0\0\0\0\0"))
+ else if(r[0] == 'g' && r[1] == 't' && !r[2])
ch = '>';
- else if(ri == *((uint64_t *)"amp\0\0\0\0"))
+ else if(r[0] == 'a' && r[1] == 'm' && r[2] == 'p' && !r[3])
ch = '&';
- else if(ri == *((uint64_t *)"apos\0\0\0"))
+ else if(r[0] == 'a' && r[1] == 'p' && r[2] == 'o' && r[3] == 's' && !r[4])
ch = '\'';
- else if(ri == *((uint64_t *)"quot\0\0\0"))
+ else if(r[0] == 'q' && r[1] == 'u' && r[2] == 'o' && r[3] == 't' && !r[4])
ch = '"';
}