-
Notifications
You must be signed in to change notification settings - Fork 29
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
[Refactoring] change qt math function to cmath analog #89
Conversation
✅ Build kepka 1.0.59-saswpqds completed (commit dd608d56cb by @pperehozhih) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement missing conversions to std::clamp
@@ -370,7 +370,7 @@ void ShareBox::Inner::repaintChatAtIndex(int index) { | |||
|
|||
auto row = index / _columnCount; | |||
auto column = index % _columnCount; | |||
update(rtlrect(_rowsLeft + qFloor(column * _rowWidthReal), row * _rowHeight, _rowWidth, _rowHeight, width())); | |||
update(rtlrect(_rowsLeft + std::floor(column * _rowWidthReal), row * _rowHeight, _rowWidth, _rowHeight, width())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tab - replace with spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean the opposite? Replace spaces with tab? Currently, Kepka codebase mainly uses tabs.
} | ||
qint32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left(); | ||
qint32 descAtY = qMin(_historyPaddingTop - descH, qMax(0, (_scroll->height() - descH) / 2)) + st::msgMargin.top(); | ||
qint32 descAtY = std::min(_historyPaddingTop - descH, std::max(0, (_scroll->height() - descH) / 2)) + st::msgMargin.top(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use clamp here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clamp cant be used here. There may be situations it will lead to undefined behavior, this constuction doesnt guarantee that second argument of std:max greater 0 and first argument of std::min greater 0, or one of these greater than other
From specs of std::clamp
"The behavior is undefined if the value of lo is greater than hi"
} | ||
qint32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left(); | ||
qint32 descAtY = qMin(newHistoryPaddingTop - descH, qMax(0, (_scroll->height() - descH) / 2)) + st::msgMargin.top(); | ||
qint32 descAtY = std::min(newHistoryPaddingTop - descH, std::max(0, (_scroll->height() - descH) / 2)) + st::msgMargin.top(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clamp cant be used here. There may be situations it will lead to undefined behavior, this constuction doesnt guarantee that second argument of std:max greater 0 and first argument of std::min greater 0, or one of these greater than other
From specs of std::clamp
"The behavior is undefined if the value of lo is greater than hi"
@@ -463,7 +463,7 @@ void HistoryMessageReply::updateName() const { | |||
w += st::msgServiceFont->spacew + _replyToVia->_maxWidth; | |||
} | |||
|
|||
_maxReplyWidth = previewSkip + qMax(w, qMin(replyToText.maxWidth(), qint32(st::maxSignatureSize))); | |||
_maxReplyWidth = previewSkip + std::max(w, std::min(replyToText.maxWidth(), qint32(st::maxSignatureSize))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clamp cant be used here. There may be situations it will lead to undefined behavior, this constuction doesnt guarantee that second argument of std:max greater 0 and first argument of std::min greater 0, or one of these greater than other
From specs of std::clamp
"The behavior is undefined if the value of lo is greater than hi"
if (_media && _media->currentWidth() < maxwidth) { | ||
maxwidth = qMax(_media->currentWidth(), qMin(maxwidth, plainMaxWidth())); | ||
maxwidth = std::max(_media->currentWidth(), std::min(maxwidth, plainMaxWidth())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clamp cant be used here. There may be situations it will lead to undefined behavior, this constuction doesnt guarantee that second argument of std:max greater 0 and first argument of std::min greater 0, or one of these greater than other
From specs of std::clamp
"The behavior is undefined if the value of lo is greater than hi"
double coef = 1. / fadeSamples, fadedFrom = d->fullSamples - skipSamples; | ||
short *ptr = srcSamplesDataChannel, *zeroEnd = ptr + qMin(samplesCnt, qMax(0, skipSamples - d->fullSamples)), *end = ptr + fadedCnt; | ||
short *ptr = srcSamplesDataChannel, *zeroEnd = ptr + std::min(samplesCnt, std::max(0, skipSamples - d->fullSamples)), *end = ptr + fadedCnt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clamp cant be used here. There may be situations it will lead to undefined behavior, this constuction doesnt guarantee that second argument of std:max greater 0 and first argument of std::min greater 0, or one of these greater than other
From specs of std::clamp
"The behavior is undefined if the value of lo is greater than hi"
qint32 maxw = qMin(qMax(width() - 2 * skipw - st::mediaviewCaptionPadding.left() - st::mediaviewCaptionPadding.right() - 2 * st::mediaviewCaptionMargin.width(), int(st::msgMinWidth)), _caption.maxWidth()); | ||
qint32 maxh = qMin(_caption.countHeight(maxw), int(height() / 4 - st::mediaviewCaptionPadding.top() - st::mediaviewCaptionPadding.bottom() - 2 * st::mediaviewCaptionMargin.height())); | ||
qint32 skipw = std::max(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width()); | ||
qint32 maxw = std::min(std::max(width() - 2 * skipw - st::mediaviewCaptionPadding.left() - st::mediaviewCaptionPadding.right() - 2 * st::mediaviewCaptionMargin.width(), int(st::msgMinWidth)), _caption.maxWidth()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clamp cant be used here. There may be situations it will lead to undefined behavior, this constuction doesnt guarantee that second argument of std:max greater 0 and first argument of std::min greater 0, or one of these greater than other
From specs of std::clamp
"The behavior is undefined if the value of lo is greater than hi"
auto skipw = qMax(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width()); | ||
auto maxw = qMin(qMax(width() - 2 * skipw - st::mediaviewCaptionPadding.left() - st::mediaviewCaptionPadding.right() - 2 * st::mediaviewCaptionMargin.width(), int(st::msgMinWidth)), _caption.maxWidth()); | ||
auto skipw = std::max(_dateNav.left() + _dateNav.width(), _headerNav.left() + _headerNav.width()); | ||
auto maxw = std::min(std::max(width() - 2 * skipw - st::mediaviewCaptionPadding.left() - st::mediaviewCaptionPadding.right() - 2 * st::mediaviewCaptionMargin.width(), int(st::msgMinWidth)), _caption.maxWidth()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clamp cant be used here. There may be situations it will lead to undefined behavior, this constuction doesnt guarantee that second argument of std:max greater 0 and first argument of std::min greater 0, or one of these greater than other
From specs of std::clamp
"The behavior is undefined if the value of lo is greater than hi"
❌ Build kepka 1.0.65-kpremwsc failed (commit 52a41b1c90 by @pperehozhih) |
…td::clamp (if it's possible)
374d4a9
to
b4e40ac
Compare
✅ Build kepka 1.0.65-eyljxsgy completed (commit 2fed5995dd by @pperehozhih) |
I consider to merge it w/o clamp changes. We will make it in next PR. |
Issue #36
change