@@ -60,6 +60,8 @@ static EventSchema parseEventSchema(
60
60
return Result;
61
61
}
62
62
63
+ #include < iostream>
64
+
63
65
// Schemas are globally loaded.
64
66
// This static/thread_local dance is to make it appropriately thread safe but
65
67
// still fast.
@@ -92,22 +94,34 @@ static Event parseEvent(const std::string_view Event) {
92
94
Event.find_first_not_of (" \t\n " , Event.find (' :' , KeyE + 1 ) + 1 );
93
95
if (ValF == std::string_view::npos)
94
96
break ;
95
- const auto ValE = Event[ValF] == ' "'
96
- ? Event.find (' "' , ValF + 1 ) + 1
97
- : Event.find_first_of (" ,} \t\n " , ValF + 1 );
97
+ const auto ValE = [&] {
98
+ if (Event[ValF] == ' "' ) {
99
+ // Find the end of the string
100
+ return Event.find (' "' , ValF
101
+ // start after the open quote
102
+ + 1 )
103
+ // include the end quote
104
+ + 1 ;
105
+ } else {
106
+ // Find the end of the number/bool/etc; either the next whitespace, the
107
+ // separating comma, or the end of the JSON object:
108
+ return Event.find_first_of (" ,} \t\n " , ValF + 1 );
109
+ }
110
+ }();
98
111
if (ValE == std::string_view::npos)
99
112
break ;
100
113
std::string_view Val = Event.substr (ValF, ValE - ValF);
101
114
102
115
Result.emplace_back (Key, Val);
103
- Begin = Event.find_first_of (" ,}" , ValE + 1 );
116
+ // Find the start of the next element (if there is a next)
117
+ Begin = Event.find_first_of (" ,}" , ValE);
104
118
if (Begin == std::string_view::npos)
105
119
break ;
106
120
Begin += 1 ;
107
121
}
108
122
109
123
assert (Result[0 ].first == " event_id" sv);
110
- EventId Id (Result[0 ].second );
124
+ EventId Id (Result[0 ].second . substr ( 1 , Result[ 0 ]. second . size () - 2 ) );
111
125
112
126
auto It = Schemas.find (Id);
113
127
if (It == Schemas.end ()) {
0 commit comments