Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move assignment of xchar to declaration #3091

Merged
merged 2 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions stl/src/xdnorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
_EXTERN_C_UNLESS_PURE

short _Dnorm(_Dval* ps) { // normalize double fraction
short xchar;
short xchar = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope is small enough here as to make no difference, but in the future I suggest moving the declaration to the initialization in preference to moving the initialization to the declaration. We generally try to limit the lifetime of objects to the portion of the code that actually uses those objects.

unsigned short sign = static_cast<unsigned short>(ps->_Sh[_D0] & _DSIGN);

xchar = 1;
if ((ps->_Sh[_D0] &= _DFRAC) != 0 || ps->_Sh[_D1] || ps->_Sh[_D2] || ps->_Sh[_D3]) { // nonzero, scale
for (; ps->_Sh[_D0] == 0; xchar -= 16) { // shift left by 16
ps->_Sh[_D0] = ps->_Sh[_D1];
Expand Down
3 changes: 1 addition & 2 deletions stl/src/xfdnorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
_EXTERN_C_UNLESS_PURE

short _FDnorm(_Fval* ps) { // normalize float fraction
short xchar;
short xchar = 1;
unsigned short sign = static_cast<unsigned short>(ps->_Sh[_F0] & _FSIGN);

xchar = 1;
if ((ps->_Sh[_F0] &= _FFRAC) != 0 || ps->_Sh[_F1]) { // nonzero, scale
if (ps->_Sh[_F0] == 0) {
ps->_Sh[_F0] = ps->_Sh[_F1];
Expand Down