From: Marcelo M. <mar...@us...> - 2005-11-23 03:10:08
|
Update of /cvsroot/swig/SWIG/Source/DOH In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26152/Source/DOH Modified Files: doh.h string.c Log Message: improve cpp performance Index: doh.h =================================================================== RCS file: /cvsroot/swig/SWIG/Source/DOH/doh.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** doh.h 7 Oct 2005 13:16:21 -0000 1.13 --- doh.h 23 Nov 2005 03:10:00 -0000 1.14 *************** *** 66,69 **** --- 66,77 ---- #define DohPutc DOH_NAMESPACE(Putc) #define DohUngetc DOH_NAMESPACE(Ungetc) + + #define DohStringGetc DOH_NAMESPACE(StringGetc) + #define DohStringPutc DOH_NAMESPACE(StringPutc) + #define DohStringUngetc DOH_NAMESPACE(StringUngetc) + #define DohStringAppend DOH_NAMESPACE(StringAppend) + + + #define DohGetline DOH_NAMESPACE(Getline) #define DohSetline DOH_NAMESPACE(Setline) *************** *** 219,222 **** --- 227,232 ---- extern int DohUngetc(int ch, DOHFile *obj); + + /* Iterators */ extern DohIterator DohFirst(DOH *obj); *************** *** 235,238 **** --- 245,258 ---- extern void DohChop(DOHString *src); + extern int DohString_putc(DOH *so, int ch); + extern int DohString_getc(DOH *so); + extern int DohString_ungetc(DOH *so, int ch); + extern void DohString_append(DOH *so, DOH *str); + + #define DohStringPutc(ch,so) DohString_putc(so, ch) + #define DohStringGetc(so) DohString_getc(so) + #define DohStringUngetc(ch,so) DohString_ungetc(so, ch) + #define DohStringAppend(so,str) DohString_append(so, str) + /* Meta-variables */ extern DOH *DohGetmeta(DOH *, const DOH *); *************** *** 356,359 **** --- 376,385 ---- #define Putc DohPutc #define Ungetc DohUngetc + + #define StringGetc DohStringGetc + #define StringPutc DohStringPutc + #define StringUngetc DohStringUngetc + #define StringAppend DohStringAppend + #define Close DohClose #define vPrintf DohvPrintf Index: string.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/DOH/string.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** string.c 26 Aug 2005 07:06:10 -0000 1.17 --- string.c 23 Nov 2005 03:10:00 -0000 1.18 *************** *** 155,165 **** /* ----------------------------------------------------------------------------- ! * static add(String *s, const char *newstr) - Append to s * ----------------------------------------------------------------------------- */ ! static void ! add(String *s, const char *newstr) { int oldlen, newlen, newmaxsize, l, i, sp; char *tc; if (!newstr) return; s->hashkey = -1; --- 155,168 ---- /* ----------------------------------------------------------------------------- ! * DohString_append(String *s, const char *newstr) - Append to s * ----------------------------------------------------------------------------- */ ! void ! DohString_append(DOH *so, DOH *str) { int oldlen, newlen, newmaxsize, l, i, sp; char *tc; + String *s = (String *) ObjData(so); + char *newstr = (char *) DohData(str); + if (!newstr) return; s->hashkey = -1; *************** *** 209,226 **** String_insert(DOH *so, int pos, DOH *str) { ! String *s = (String *) ObjData(so); char *nstr; int len; char *data; - data = (char *) DohData(str); - nstr = s->str; - - s->hashkey = -1; if (pos == DOH_END) { ! add(s, data); return 0; } if (pos < 0) pos = 0; else if (pos > s->len) pos = s->len; --- 212,231 ---- String_insert(DOH *so, int pos, DOH *str) { ! String *s; char *nstr; int len; char *data; if (pos == DOH_END) { ! DohString_append(so, str); return 0; } + s = (String *) ObjData(so); + s->hashkey = -1; + data = (char *) DohData(str); + nstr = s->str; + + if (pos < 0) pos = 0; else if (pos > s->len) pos = s->len; *************** *** 418,423 **** * ----------------------------------------------------------------------------- */ ! static int ! String_putc(DOH *so, int ch) { register int len, maxsize, sp; --- 423,428 ---- * ----------------------------------------------------------------------------- */ ! int ! DohString_putc(DOH *so, int ch) { register int len, maxsize, sp; *************** *** 430,436 **** maxsize = s->maxsize; if (len > (maxsize-2)) { ! s->str = (char *) DohRealloc(s->str,2*maxsize); assert(s->str); ! s->maxsize = 2*maxsize; } tc = s->str + len; --- 435,441 ---- maxsize = s->maxsize; if (len > (maxsize-2)) { ! s->str = (char *) DohRealloc(s->str,3*maxsize); assert(s->str); ! s->maxsize = 3*maxsize; } tc = s->str + len; *************** *** 453,458 **** * ----------------------------------------------------------------------------- */ ! static int ! String_getc(DOH *so) { int c; --- 458,463 ---- * ----------------------------------------------------------------------------- */ ! int ! DohString_getc(DOH *so) { int c; *************** *** 470,475 **** * ----------------------------------------------------------------------------- */ ! static int ! String_ungetc(DOH *so, int ch) { String *s = (String *) ObjData(so); --- 475,480 ---- * ----------------------------------------------------------------------------- */ ! int ! DohString_ungetc(DOH *so, int ch) { String *s = (String *) ObjData(so); *************** *** 481,485 **** } - /* ----------------------------------------------------------------------------- * replace_simple(String *str, char *token, char *rep, int flags, int count) --- 486,489 ---- *************** *** 883,889 **** String_read, String_write, ! String_putc, ! String_getc, ! String_ungetc, String_seek, String_tell, --- 887,893 ---- String_read, String_write, ! DohString_putc, ! DohString_getc, ! DohString_ungetc, String_seek, String_tell, |