mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
AP_Frsky_Telem: return a reference from AP::mission()
Every vehicle which compiles mission support in also instantiates an AP_Mission object, so the singleton is never null. Returning a reference rather than a pointer says so, and lets the nullptr checks at each call site go away. Saves around 150 bytes of flash per firmware.
This commit is contained in:
committed by
Peter Barker
parent
24834fbad8
commit
96eaea3d16
@@ -262,10 +262,7 @@ bool AP_Frsky_SPort_Passthrough::is_packet_ready(uint8_t idx, bool queue_empty)
|
||||
break;
|
||||
#if AP_MISSION_ENABLED
|
||||
case WAYPOINT:
|
||||
{
|
||||
const AP_Mission *mission = AP::mission();
|
||||
packet_ready = mission != nullptr && mission->get_current_nav_index() > 0;
|
||||
}
|
||||
packet_ready = AP::mission().get_current_nav_index() > 0;
|
||||
break;
|
||||
#endif // AP_MISSION_ENABLED
|
||||
case UDATA:
|
||||
@@ -802,9 +799,8 @@ uint32_t AP_Frsky_SPort_Passthrough::calc_wind(void)
|
||||
#if AP_MISSION_ENABLED
|
||||
uint32_t AP_Frsky_SPort_Passthrough::calc_waypoint(void)
|
||||
{
|
||||
const AP_Mission *mission = AP::mission();
|
||||
const AP_Vehicle *vehicle = AP::vehicle();
|
||||
if (mission == nullptr || vehicle == nullptr) {
|
||||
if (vehicle == nullptr) {
|
||||
return 0U;
|
||||
}
|
||||
float wp_distance;
|
||||
@@ -816,7 +812,7 @@ uint32_t AP_Frsky_SPort_Passthrough::calc_waypoint(void)
|
||||
return 0U;
|
||||
}
|
||||
// waypoint current nav index
|
||||
uint32_t value = MIN(mission->get_current_nav_index(), WP_NUMBER_LIMIT);
|
||||
uint32_t value = MIN(AP::mission().get_current_nav_index(), WP_NUMBER_LIMIT);
|
||||
// distance to next waypoint
|
||||
value |= prep_number(wp_distance, 3, 2) << WP_DISTANCE_OFFSET;
|
||||
// bearing encoded in 3 degrees increments
|
||||
|
||||
Reference in New Issue
Block a user