Skip to content

Commit

Permalink
reuse protobuf message
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Nov 14, 2024
1 parent e3e83f7 commit 4686575
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 7 additions & 0 deletions include/nigiri/rt/gtfsrt_update.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ statistics gtfsrt_update_msg(timetable const&,
std::string_view tag,
transit_realtime::FeedMessage const&);

statistics gtfsrt_update_buf(timetable const& tt,
rt_timetable& rtt,
source_idx_t const src,
std::string_view tag,
std::string_view protobuf,
transit_realtime::FeedMessage& msg);

statistics gtfsrt_update_buf(timetable const&,
rt_timetable&,
source_idx_t const,
Expand Down
14 changes: 12 additions & 2 deletions src/rt/gtfsrt_update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,9 @@ statistics gtfsrt_update_buf(timetable const& tt,
rt_timetable& rtt,
source_idx_t const src,
std::string_view tag,
std::string_view protobuf) {
gtfsrt::FeedMessage msg;
std::string_view protobuf,
gtfsrt::FeedMessage& msg) {
msg.Clear();

auto const success =
msg.ParseFromArray(reinterpret_cast<void const*>(protobuf.data()),
Expand All @@ -383,4 +384,13 @@ statistics gtfsrt_update_buf(timetable const& tt,
return gtfsrt_update_msg(tt, rtt, src, tag, msg);
}

statistics gtfsrt_update_buf(timetable const& tt,
rt_timetable& rtt,
source_idx_t const src,
std::string_view tag,
std::string_view protobuf) {
auto msg = gtfsrt::FeedMessage{};
return gtfsrt_update_buf(tt, rtt, src, tag, protobuf, msg);
}

} // namespace nigiri::rt

0 comments on commit 4686575

Please sign in to comment.