Skip to content

Commit ec2dda0

Browse files
committed
Guider's CurrentImage is never null
Remove some unnecessary null checks for Guider::CurrentImage(). Although the checks are harmless, they make the code a bit harder to understand as readers may be wondering about how or why the current image could be null (it cannot!).
1 parent 3376286 commit ec2dda0

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/guider.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,6 @@ bool Guider::MoveLockPosition(const PHD_Point& mountDeltaArg)
852852
}
853853

854854
const usImage *image = CurrentImage();
855-
if (!image)
856-
{
857-
throw ERROR_INFO("cannot move lock pos without an image");
858-
}
859855

860856
// This loop is to handle dithers when the star is near the edge of the frame. The strategy
861857
// is to try reflecting the requested dither in 4 directions along the RA/Dec axes; if any

src/guider_multistar.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ bool GuiderMultiStar::AutoSelect(const wxRect& roi)
452452

453453
try
454454
{
455-
if (!image || !image->ImageData)
455+
if (!image->ImageData)
456456
{
457457
throw ERROR_INFO("No Current Image");
458458
}
@@ -519,7 +519,7 @@ bool GuiderMultiStar::AutoSelect(const wxRect& roi)
519519
error = true;
520520
}
521521

522-
if (image && image->ImageData)
522+
if (image->ImageData)
523523
{
524524
if (error)
525525
Debug.Write("GuiderMultiStar::AutoSelect failed.\n");
@@ -1078,8 +1078,6 @@ bool GuiderMultiStar::SetLockPosition(const PHD_Point& position)
10781078
bool GuiderMultiStar::IsValidLockPosition(const PHD_Point& pt)
10791079
{
10801080
const usImage *pImage = CurrentImage();
1081-
if (!pImage)
1082-
return false;
10831081
// this is a bit ugly as it is tightly coupled to Star::Find
10841082
return pt.X >= 1 + m_searchRegion && pt.X + 1 + m_searchRegion < pImage->Size.GetX() && pt.Y >= 1 + m_searchRegion &&
10851083
pt.Y + 1 + m_searchRegion < pImage->Size.GetY();
@@ -1088,8 +1086,6 @@ bool GuiderMultiStar::IsValidLockPosition(const PHD_Point& pt)
10881086
bool GuiderMultiStar::IsValidSecondaryStarPosition(const PHD_Point& pt)
10891087
{
10901088
const usImage *pImage = CurrentImage();
1091-
if (!pImage)
1092-
return false;
10931089
// As above, tightly coupled to Star::Find but with somewhat relaxed constraints. Find handles cases where search region is
10941090
// only partly within image
10951091
return pt.X >= 5 && pt.X + 5 < pImage->Size.GetX() && pt.Y >= 5 && pt.Y + 5 < pImage->Size.GetY();

0 commit comments

Comments
 (0)