Kirill Simonov avatar Kirill Simonov committed 4af707e

Do not update the raw buffer when not necessary (fixes #123).

Comments (0)

Files changed (1)

 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. */
 
     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. */
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.