From: Braden M. <br...@us...> - 2006-02-26 09:57:40
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29927/src/libopenvrml/openvrml Modified Files: Vrml97Parser.g Log Message: Use atof, atol, strtol to convert numeric values in the parser. These are sufficient (given the validation done implicitly in the scanner) and faster than using stringstreams. From Andrew Grieve <sg...@us...> Index: Vrml97Parser.g =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/Vrml97Parser.g,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** Vrml97Parser.g 26 Feb 2006 08:32:31 -0000 1.47 --- Vrml97Parser.g 26 Feb 2006 09:57:35 -0000 1.48 *************** *** 1851,1856 **** floatValue returns [float val] options { defaultErrorHandler=false; } ! : f0:REAL { std::istringstream(f0->getText()) >> val; } ! | f1:INTEGER { std::istringstream(f1->getText()) >> val; } ; --- 1851,1856 ---- floatValue returns [float val] options { defaultErrorHandler=false; } ! : f0:REAL { val = float(atof(f0->getText().c_str())); } ! | f1:INTEGER { val = float(atol(f1->getText().c_str())); } ; *************** *** 1915,1925 **** intValue returns [int32 val] options { defaultErrorHandler=false; } ! : i0:INTEGER { ! std::istringstream(i0->getText()) >> val; } | i1:HEX_INTEGER { ! unsigned long unsigned_val; ! std::istringstream(i1->getText()) >> std::hex >> unsigned_val; ! val = int32(unsigned_val); } ; --- 1915,1923 ---- intValue returns [int32 val] options { defaultErrorHandler=false; } ! : i0:INTEGER { ! val = atol(i0->getText().c_str()); } | i1:HEX_INTEGER { ! val = int32(strtoul(i1->getText().c_str() + 2, 0, 16)); } ; *************** *** 2157,2162 **** doubleValue returns [double val = 0.0] options { defaultErrorHandler=false; } ! : d0:REAL { std::istringstream(d0->getText()) >> val; } ! | d1:INTEGER { std::istringstream(d1->getText()) >> val; } ; --- 2155,2160 ---- doubleValue returns [double val = 0.0] options { defaultErrorHandler=false; } ! : d0:REAL { val = atof(d0->getText().c_str()); } ! | d1:INTEGER { val = double(atol(d1->getText().c_str())); } ; |