Skip to content

Commit 8897599

Browse files
committed
Remove unnecessary heap allocation
1 parent ec71e18 commit 8897599

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

gpsd_client/src/client.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,23 +219,23 @@ class GPSDClient {
219219
}
220220

221221
void process_data_navsat(struct gps_data_t* p) {
222-
NavSatFixPtr fix(new NavSatFix);
222+
NavSatFix fix;
223223

224224
/* TODO: Support SBAS and other GBAS. */
225225

226226
#if GPSD_API_MAJOR_VERSION >= 9
227227
if (use_gps_time && (p->online.tv_sec || p->online.tv_nsec)) {
228-
fix->header.stamp = ros::Time(p->fix.time.tv_sec, p->fix.time.tv_nsec);
228+
fix.header.stamp = ros::Time(p->fix.time.tv_sec, p->fix.time.tv_nsec);
229229
#else
230230
if (use_gps_time && !std::isnan(p->fix.time)) {
231-
fix->header.stamp = ros::Time(p->fix.time);
231+
fix.header.stamp = ros::Time(p->fix.time);
232232
#endif
233233
}
234234
else {
235-
fix->header.stamp = ros::Time::now();
235+
fix.header.stamp = ros::Time::now();
236236
}
237237

238-
fix->header.frame_id = frame_id;
238+
fix.header.frame_id = frame_id;
239239

240240
/* gpsmm pollutes the global namespace with STATUS_,
241241
* so we need to use the ROS message's integer values
@@ -251,7 +251,7 @@ class GPSDClient {
251251
#else
252252
case STATUS_NO_FIX:
253253
#endif
254-
fix->status.status = 0; // NavSatStatus::STATUS_FIX or NavSatStatus::STATUS_GPS;
254+
fix.status.status = 0; // NavSatStatus::STATUS_FIX or NavSatStatus::STATUS_GPS;
255255
break;
256256
// STATUS_DGPS_FIX was removed in API version 6 but re-added afterward and next renamed since the version 12
257257
#if GPSD_API_MAJOR_VERSION != 6
@@ -260,16 +260,16 @@ class GPSDClient {
260260
#else
261261
case STATUS_DGPS_FIX:
262262
#endif
263-
fix->status.status = 2; // NavSatStatus::STATUS_GBAS_FIX;
263+
fix.status.status = 2; // NavSatStatus::STATUS_GBAS_FIX;
264264
break;
265265
#endif
266266
}
267267

268-
fix->status.service = NavSatStatus::SERVICE_GPS;
268+
fix.status.service = NavSatStatus::SERVICE_GPS;
269269

270-
fix->latitude = p->fix.latitude;
271-
fix->longitude = p->fix.longitude;
272-
fix->altitude = p->fix.altitude;
270+
fix.latitude = p->fix.latitude;
271+
fix.longitude = p->fix.longitude;
272+
fix.altitude = p->fix.altitude;
273273

274274
/* gpsd reports status=OK even when there is no current fix,
275275
* as long as there has been a fix previously. Throw out these
@@ -281,11 +281,11 @@ class GPSDClient {
281281
return;
282282
}
283283

284-
fix->position_covariance[0] = p->fix.epx;
285-
fix->position_covariance[4] = p->fix.epy;
286-
fix->position_covariance[8] = p->fix.epv;
284+
fix.position_covariance[0] = p->fix.epx;
285+
fix.position_covariance[4] = p->fix.epy;
286+
fix.position_covariance[8] = p->fix.epv;
287287

288-
fix->position_covariance_type = NavSatFix::COVARIANCE_TYPE_DIAGONAL_KNOWN;
288+
fix.position_covariance_type = NavSatFix::COVARIANCE_TYPE_DIAGONAL_KNOWN;
289289

290290
navsat_fix_pub.publish(fix);
291291
}

0 commit comments

Comments
 (0)