]> andersk Git - libyaml.git/commitdiff
Do not update the raw buffer when not necessary (fixes #123).
authorKirill Simonov <xi@resolvent.net>
Sat, 29 Aug 2009 21:26:11 +0000 (21:26 +0000)
committerKirill Simonov <xi@resolvent.net>
Sat, 29 Aug 2009 21:26:11 +0000 (21:26 +0000)
src/reader.c

index 6fc1a621707913c792bce15c174db196d94cffef..829e32da55c0bee1baf572d72b574076a7ca52eb 100644 (file)
@@ -141,6 +141,8 @@ yaml_parser_update_raw_buffer(yaml_parser_t *parser)
 YAML_DECLARE(int)
 yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
 {
+    int first = 1;
+
     assert(parser->read_handler);   /* Read handler must be set. */
 
     /* If the EOF flag is set and the raw buffer is empty, do nothing. */
@@ -178,9 +180,12 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
 
     while (parser->unread < length)
     {
-        /* Fill the raw buffer. */
+        /* Fill the raw buffer if necessary. */
 
-        if (!yaml_parser_update_raw_buffer(parser)) return 0;
+        if (!first || parser->raw_buffer.pointer == parser->raw_buffer.last) {
+            if (!yaml_parser_update_raw_buffer(parser)) return 0;
+        }
+        first = 0;
 
         /* Decode the raw buffer. */
 
This page took 0.053471 seconds and 5 git commands to generate.