Merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Paul J. Lucas
Approved revision: 11472
Merged at revision: 11706
Proposed branch: lp:~paul-lucas/zorba/pjl-misc
Merge into: lp:zorba
Diff against target: 140 lines (+37/-14)
6 files modified
include/zorba/util/mem_streambuf.h (+1/-0)
src/api/mem_streambuf.cpp (+0/-1)
src/runtime/csv/csv_impl.cpp (+8/-9)
src/runtime/csv/csv_util.h (+22/-0)
src/runtime/csv/pregenerated/csv.h (+3/-2)
src/runtime/spec/csv/csv.xml (+3/-2)
To merge this branch: bzr merge lp:~paul-lucas/zorba/pjl-misc
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Paul J. Lucas Approve
Review via email: mp+209825@code.launchpad.net

Commit message

Maintaining more state to avoid construction/allocation/destruction of istringstream.

Description of the change

Maintaining more state to avoid construction/allocation/destruction of istringstream.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/209825

Progress dashboard at http://jenkins.zorba.io:8180/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/209825

Stage "BuildZorbaUbuntu" failed.

Check compiler output at http://jenkins.zorba.io:8180/job/BuildZorbaUbuntu/540/parsed_console to view the results.

lp:~paul-lucas/zorba/pjl-misc updated
11473. By Paul J. Lucas

Fixed build.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/209825

Progress dashboard at http://jenkins.zorba.io:8180/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue succeeded - proposal merged!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/zorba/util/mem_streambuf.h'
2--- include/zorba/util/mem_streambuf.h 2014-01-10 23:53:58 +0000
3+++ include/zorba/util/mem_streambuf.h 2014-03-07 05:56:59 +0000
4@@ -22,6 +22,7 @@
5
6 // Zorba
7 #include <zorba/config.h>
8+#include <zorba/internal/cxx_util.h>
9
10 namespace zorba {
11
12
13=== modified file 'src/api/mem_streambuf.cpp'
14--- src/api/mem_streambuf.cpp 2013-12-27 15:11:16 +0000
15+++ src/api/mem_streambuf.cpp 2014-03-07 05:56:59 +0000
16@@ -17,7 +17,6 @@
17 #include "stdafx.h"
18 #include <cstring> /* for memcpy(3) */
19
20-#include <zorba/internal/cxx_util.h>
21 #include <zorba/util/mem_streambuf.h>
22
23 #include "diagnostics/assert.h"
24
25=== modified file 'src/runtime/csv/csv_impl.cpp'
26--- src/runtime/csv/csv_impl.cpp 2014-03-06 19:06:43 +0000
27+++ src/runtime/csv/csv_impl.cpp 2014-03-07 05:56:59 +0000
28@@ -157,11 +157,10 @@
29 return false;
30 }
31
32-static json::type parse_json( zstring const &s, json::token *ptoken ) {
33- mem_streambuf buf( (char*)s.data(), s.size() );
34- istringstream iss;
35- iss.ios::rdbuf( &buf );
36- json::lexer lex( iss );
37+static json::type parse_json( zstring const &s, csv_parse_json_state &state,
38+ json::token *ptoken ) {
39+ state.set_data( s.data(), s.size() );
40+ json::lexer lex( state.iss_ );
41 if ( !lex.next( ptoken, false ) )
42 return json::none;
43 json::token::type const tt = ptoken->get_type();
44@@ -221,9 +220,9 @@
45 state->csv_.set_stream( item->getStream() );
46 else {
47 item->getStringValue2( state->string_ );
48- state->mem_streambuf_.set( state->string_.data(), state->string_.size() );
49- state->iss_.ios::rdbuf( &state->mem_streambuf_ );
50- state->csv_.set_stream( state->iss_ );
51+ state->input_buf_.set( state->string_.data(), state->string_.size() );
52+ state->input_iss_.ios::rdbuf( &state->input_buf_ );
53+ state->csv_.set_stream( state->input_iss_ );
54 }
55 }
56
57@@ -428,7 +427,7 @@
58 GENV_ITEMFACTORY->createBoolean( item, false );
59 else {
60 json::token t;
61- switch ( parse_json( *value, &t ) ) {
62+ switch ( parse_json( *value, state->parse_json_state_, &t ) ) {
63 case json::boolean:
64 GENV_ITEMFACTORY->createBoolean( item, (*value)[0] == 't' );
65 break;
66
67=== modified file 'src/runtime/csv/csv_util.h'
68--- src/runtime/csv/csv_util.h 2013-08-23 00:43:04 +0000
69+++ src/runtime/csv/csv_util.h 2014-03-07 05:56:59 +0000
70@@ -17,10 +17,32 @@
71 #ifndef ZORBA_CSV_UTIL_H
72 #define ZORBA_CSV_UTIL_H
73
74+// standard
75+#include <sstream>
76+
77+// Zorba
78+#include <zorba/util/mem_streambuf.h>
79+
80 namespace zorba {
81
82 ///////////////////////////////////////////////////////////////////////////////
83
84+struct csv_parse_json_state {
85+ std::istringstream iss_;
86+
87+ csv_parse_json_state() {
88+ iss_.std::ios::rdbuf( &buf_ );
89+ }
90+
91+ void set_data( char const *s, size_t size ) {
92+ buf_.set( const_cast<char*>( s ), size );
93+ iss_.seekg( 0 );
94+ }
95+
96+private:
97+ mem_streambuf buf_;
98+};
99+
100 namespace missing {
101 enum type {
102 null,
103
104=== modified file 'src/runtime/csv/pregenerated/csv.h'
105--- src/runtime/csv/pregenerated/csv.h 2014-03-06 19:06:43 +0000
106+++ src/runtime/csv/pregenerated/csv.h 2014-03-07 05:56:59 +0000
107@@ -50,11 +50,12 @@
108 bool cast_unquoted_; //
109 csv_parser csv_; //
110 zstring extra_name_; //
111- std::istringstream iss_; //
112+ mem_streambuf input_buf_; //
113+ std::istringstream input_iss_; //
114 std::vector<store::Item_t> keys_; //
115 unsigned line_no_; //
116- mem_streambuf mem_streambuf_; //
117 missing::type missing_; //
118+ csv_parse_json_state parse_json_state_; //
119 bool skip_called_; //
120 zstring string_; //
121 zstring value_; //
122
123=== modified file 'src/runtime/spec/csv/csv.xml'
124--- src/runtime/spec/csv/csv.xml 2014-03-06 19:06:43 +0000
125+++ src/runtime/spec/csv/csv.xml 2014-03-07 05:56:59 +0000
126@@ -32,11 +32,12 @@
127 <zorba:member type="bool" name="cast_unquoted_" defaultValue="true"/>
128 <zorba:member type="csv_parser" name="csv_"/>
129 <zorba:member type="zstring" name="extra_name_"/>
130- <zorba:member type="std::istringstream" name="iss_"/>
131+ <zorba:member type="mem_streambuf" name="input_buf_"/>
132+ <zorba:member type="std::istringstream" name="input_iss_"/>
133 <zorba:member type="std::vector&lt;store::Item_t&gt;" name="keys_"/>
134 <zorba:member type="unsigned" name="line_no_" defaultValue="1"/>
135- <zorba:member type="mem_streambuf" name="mem_streambuf_"/>
136 <zorba:member type="missing::type" name="missing_" defaultValue="missing::null"/>
137+ <zorba:member type="csv_parse_json_state" name="parse_json_state_"/>
138 <zorba:member type="bool" name="skip_called_" defaultValue="false"/>
139 <zorba:member type="zstring" name="string_"/>
140 <zorba:member type="zstring" name="value_"/>

Subscribers

People subscribed via source and target branches