Remove unneeded std::bind, and use const & for input parameters.

This commit is contained in:
James Chen 2016-07-22 18:37:43 +08:00
parent 662a1636c3
commit bf80f10dfd
2 changed files with 6 additions and 6 deletions

View File

@ -648,8 +648,8 @@ protected:
bool multilineTextWrapByChar();
bool multilineTextWrapByWord();
bool multilineTextWrap(std::function<int(const std::u16string&, int, int)> lambda);
void shrinkLabelToContentSize(std::function<bool(void)> lambda);
bool multilineTextWrap(const std::function<int(const std::u16string&, int, int)>& lambda);
void shrinkLabelToContentSize(const std::function<bool(void)>& lambda);
bool isHorizontalClamp();
bool isVerticalClamp();
float getRenderingFontSize()const;

View File

@ -130,7 +130,7 @@ void Label::updateBMFontScale()
}
}
bool Label::multilineTextWrap(std::function<int(const std::u16string&, int, int)> nextTokenLen)
bool Label::multilineTextWrap(const std::function<int(const std::u16string&, int, int)>& nextTokenLen)
{
int textLen = getStringLength();
int lineIndex = 0;
@ -270,12 +270,12 @@ bool Label::multilineTextWrap(std::function<int(const std::u16string&, int, int)
bool Label::multilineTextWrapByWord()
{
return multilineTextWrap(std::bind(CC_CALLBACK_3(Label::getFirstWordLen, this), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
return multilineTextWrap(CC_CALLBACK_3(Label::getFirstWordLen, this));
}
bool Label::multilineTextWrapByChar()
{
return multilineTextWrap(std::bind(CC_CALLBACK_3(Label::getFirstCharLen, this) , std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
return multilineTextWrap(CC_CALLBACK_3(Label::getFirstCharLen, this));
}
bool Label::isVerticalClamp()
@ -325,7 +325,7 @@ bool Label::isHorizontalClamp()
return letterClamp;
}
void Label::shrinkLabelToContentSize(std::function<bool(void)> lambda)
void Label::shrinkLabelToContentSize(const std::function<bool(void)>& lambda)
{
float fontSize = this->getRenderingFontSize();