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

Code refactor for readability #339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Components/Overlay/src/OgreOverlayElementCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace Ogre
}
void CmdMaterial::doSet( void *target, const String &val )
{
if( val != "" )
if( !val.empty() )
{
static_cast<OverlayElement *>( target )->setMaterialName( val );
}
Expand Down
8 changes: 4 additions & 4 deletions OgreMain/src/OgreMeshSerializerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ namespace Ogre
unsigned short lodNum, MeshLodUsage &usage,
uint8 casterPass )
{
usage.manualName = "";
usage.manualName.clear();

// Get one set of detail per SubMesh
unsigned numSubs, i;
Expand Down Expand Up @@ -3243,7 +3243,7 @@ namespace Ogre
unsigned short lodNum,
MeshLodUsage &usage, uint8 casterPass )
{
usage.manualName = "";
usage.manualName.clear();
usage.manualMesh.reset();
pushInnerChunk( stream );
{
Expand Down Expand Up @@ -3431,7 +3431,7 @@ namespace Ogre
readFloats( stream, &( usage.userValue ), 1 );

// Set default values
usage.manualName = "";
usage.manualName.clear();
usage.manualMesh.reset();
usage.edgeData = NULL;

Expand Down Expand Up @@ -3835,7 +3835,7 @@ namespace Ogre
usage.userValue = Math::Sqrt( usage.value );

// Set default values
usage.manualName = "";
usage.manualName.clear();
usage.manualMesh.reset();
usage.edgeData = NULL;

Expand Down
2 changes: 1 addition & 1 deletion OgreMain/src/OgreOldNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace Ogre
mListener( 0 )
{
// Generate a name
mName = "";
mName.clear();

needUpdate();
}
Expand Down
10 changes: 5 additions & 5 deletions OgreMain/src/OgreProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ namespace Ogre

// empty string is reserved for the root
// not really fatal anymore, however one shouldn't name one's profile as an empty string anyway.
assert( ( profileName != "" ) && ( "Profile name can't be an empty string" ) );
assert( ( !profileName.empty() ) && ( "Profile name can't be an empty string" ) );

// this would be an internal error.
assert( mCurrent );
Expand Down Expand Up @@ -355,7 +355,7 @@ namespace Ogre
const uint64 endTime = mTimer->getMicroseconds();

// empty string is reserved for designating an empty parent
assert( ( profileName != "" ) && ( "Profile name can't be an empty string" ) );
assert( ( !profileName.empty() ) && ( "Profile name can't be an empty string" ) );

// we only process this profile if isn't disabled
// we check the current instance name against the provided profileName as a guard against
Expand Down Expand Up @@ -533,7 +533,7 @@ namespace Ogre
//-----------------------------------------------------------------------
bool Profiler::watchForMax( const String &profileName )
{
assert( ( profileName != "" ) && ( "Profile name can't be an empty string" ) );
assert( ( !profileName.empty() ) && ( "Profile name can't be an empty string" ) );

return mRoot.watchForMax( profileName );
}
Expand All @@ -553,7 +553,7 @@ namespace Ogre
//-----------------------------------------------------------------------
bool Profiler::watchForMin( const String &profileName )
{
assert( ( profileName != "" ) && ( "Profile name can't be an empty string" ) );
assert( ( !profileName.empty() ) && ( "Profile name can't be an empty string" ) );
return mRoot.watchForMin( profileName );
}
//-----------------------------------------------------------------------
Expand All @@ -572,7 +572,7 @@ namespace Ogre
//-----------------------------------------------------------------------
bool Profiler::watchForLimit( const String &profileName, Real limit, bool greaterThan )
{
assert( ( profileName != "" ) && ( "Profile name can't be an empty string" ) );
assert( ( !profileName.empty() ) && ( "Profile name can't be an empty string" ) );
return mRoot.watchForLimit( profileName, limit, greaterThan );
}
//-----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion OgreMain/src/OgreRenderSystemCapabilitiesSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ namespace Ogre

// skip empty and comment lines
// TODO: handle end of line comments
if (tokens[0] == "" || tokens[0].substr(0,2) == "//")
if (tokens[0].empty() || tokens[0].substr(0,2) == "//")
continue;

switch (parseAction)
Expand Down
8 changes: 4 additions & 4 deletions OgreMain/src/OgreScriptLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ namespace Ogre
if( c == slash && lastc == slash )
{
// Comment start, clear out the lexeme
lexeme = "";
lexeme.clear();
state = COMMENT;
}
else if( c == star && lastc == slash )
{
lexeme = "";
lexeme.clear();
state = MULTICOMMENT;
}
else if( c == quote )
Expand Down Expand Up @@ -131,13 +131,13 @@ namespace Ogre
case POSSIBLECOMMENT:
if( c == slash && lastc == slash )
{
lexeme = "";
lexeme.clear();
state = COMMENT;
break;
}
else if( c == star && lastc == slash )
{
lexeme = "";
lexeme.clear();
state = MULTICOMMENT;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion OgreMain/src/OgreScriptTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6374,7 +6374,7 @@ namespace Ogre{
fsaa = atom->value;
break;
case ID_MSAA_AUTO:
fsaa = "";
fsaa.clear();
break;
case ID_EXPLICIT_RESOLVE:
textureFlags |= TextureFlags::MsaaExplicitResolve;
Expand Down
4 changes: 2 additions & 2 deletions RenderSystems/Direct3D11/src/OgreD3D11HLSLProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ namespace Ogre
//-----------------------------------------------------------------------
void D3D11HLSLProgram::setTarget( const String &target )
{
mTarget = "";
mTarget.clear();
vector<String>::type profiles = StringUtil::split( target, " " );
for( unsigned int i = 0; i < profiles.size(); i++ )
{
Expand All @@ -1662,7 +1662,7 @@ namespace Ogre
}
}

if( mTarget == "" )
if( mTarget.empty() )
{
LogManager::getSingleton().logMessage( "Invalid target for D3D11 shader '" + mName +
"' - '" + target + "'" );
Expand Down
6 changes: 3 additions & 3 deletions Tools/MeshTool/include/XML/tinyxml.h
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ class TiXmlDocument : public TiXmlNode
*/
void ClearError() { error = false;
errorId = 0;
errorDesc = "";
errorDesc.clear();
errorLocation.row = errorLocation.col = 0;
//errorLocation.last = 0;
}
Expand Down Expand Up @@ -1739,8 +1739,8 @@ class TiXmlPrinter : public TiXmlVisitor
/** Switch over to "stream printing" which is the most dense formatting without
linebreaks. Common when the XML is needed for network transmission.
*/
void SetStreamPrinting() { indent = "";
lineBreak = "";
void SetStreamPrinting() { indent.clear();
lineBreak.clear();
}
/// Return the result.
const char* CStr() { return buffer.c_str(); }
Expand Down
2 changes: 1 addition & 1 deletion Tools/MeshTool/src/XML/OgreXMLMeshSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ namespace v1 {
const LodStrategy *lodStrategy = LodStrategyManager::getSingleton().getStrategy( mMesh->getLodStrategyName() );
usage.value = lodStrategy->transformUserValue(usage.userValue);
usage.manualMesh.reset();
usage.manualName = "";
usage.manualName.clear();
usage.edgeData = NULL;

mMesh->_setLodUsage(index, usage);
Expand Down
18 changes: 9 additions & 9 deletions Tools/MeshTool/src/XML/tinyxmlparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncodi
// Oddly, not supported on some comilers,
//name->clear();
// So use this:
*name = "";
name->clear();
assert( p );

// Names start with letters or underscores.
Expand Down Expand Up @@ -586,7 +586,7 @@ const char* TiXmlBase::ReadText( const char* p,
bool caseInsensitive,
TiXmlEncoding encoding )
{
*text = "";
text->clear();
if ( !trimWhiteSpace // certain tags always keep whitespace
|| !condenseWhiteSpace ) // if true, whitespace is always kept
{
Expand Down Expand Up @@ -1291,7 +1291,7 @@ const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
return 0;
}
++p;
value = "";
value.clear();

while ( p && *p && *p != '>' )
{
Expand Down Expand Up @@ -1339,7 +1339,7 @@ void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag )
const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
{
TiXmlDocument* document = GetDocument();
value = "";
value.clear();

p = SkipWhiteSpace( p, encoding );

Expand Down Expand Up @@ -1420,7 +1420,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
// All attribute values should be in single or double quotes.
// But this is such a common error that the parser will try
// its best, even without them.
value = "";
value.clear();
while ( p && *p // existence
&& !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace
&& *p != '/' && *p != '>' ) // tag end
Expand Down Expand Up @@ -1473,7 +1473,7 @@ void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag )

const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
{
value = "";
value.clear();
TiXmlDocument* document = GetDocument();

if ( data )
Expand Down Expand Up @@ -1563,9 +1563,9 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXm
}
p += 5;

version = "";
encoding = "";
standalone = "";
version.clear();
encoding.clear();
standalone.clear();

while ( p && *p )
{
Expand Down
48 changes: 24 additions & 24 deletions Tools/MeshTool/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,10 @@ void buildLod(v1::MeshPtr& mesh)
else
{
std::cout << "Wrong answer!\n";
response = "";
response.clear();
}
}
while( response == "" );
while( response.empty() );
}
else if (askLodDtls)
{
Expand All @@ -490,10 +490,10 @@ void buildLod(v1::MeshPtr& mesh)
else
{
std::cout << "Wrong answer!\n";
response = "";
response.clear();
}
}
while( response == "" );
while( response.empty() );
}
}

Expand Down Expand Up @@ -523,10 +523,10 @@ void buildLod(v1::MeshPtr& mesh)
else
{
std::cout << "Wrong answer!\n";
response = "";
response.clear();
}
}
while (response == "");
while (response.empty());
if (!opts.lodAutoconfigure)
{
do
Expand All @@ -545,10 +545,10 @@ void buildLod(v1::MeshPtr& mesh)
else
{
std::cout << "Wrong answer!\n";
response = "";
response.clear();
}
}
while (response == "");
while (response.empty());
LodLevel lodLevel;
size_t vertexCount = 0;
do
Expand All @@ -570,10 +570,10 @@ void buildLod(v1::MeshPtr& mesh)
else
{
std::cout << "Wrong answer!\n";
response = "";
response.clear();
}
}
while (response == "");
while (response.empty());

numLod = 0;
while (numLod < 1 || numLod > 99)
Expand Down Expand Up @@ -654,10 +654,10 @@ void buildLod(v1::MeshPtr& mesh)
else
{
std::cout << "Wrong answer!\n";
response = "";
response.clear();
}
}
while (response == "");
while (response.empty());

if (lodConfig.strategy == DistanceLodStrategy::getSingletonPtr())
{
Expand Down Expand Up @@ -829,7 +829,7 @@ void resolveColourAmbiguities(v1::Mesh* mesh)
else
{
std::cout << "Wrong answer!\n";
response = "";
response.clear();
}
}
}
Expand All @@ -847,7 +847,7 @@ void resolveColourAmbiguities(v1::Mesh* mesh)
{
if (opts.interactive)
{
response = "";
response.clear();
std::cout << "\nYour mesh has vertex colours, which can be stored in one of two layouts,\n"
<< "each of which will be slightly faster to load in a different render system.\n"
<< "Do you want to prefer Direct3D (d3d) or OpenGL (gl)?\n";
Expand All @@ -866,7 +866,7 @@ void resolveColourAmbiguities(v1::Mesh* mesh)
else
{
std::cout << "Wrong answer!\n";
response = "";
response.clear();
}
}
}
Expand Down Expand Up @@ -1225,15 +1225,15 @@ int main(int numargs, char** args)
unOptList["-U"] = false;
unOptList["-v1"]= false;
unOptList["-v2"]= false;
binOptList["-l"] = "";
binOptList["-d"] = "";
binOptList["-p"] = "";
binOptList["-f"] = "";
binOptList["-E"] = "";
binOptList["-td"] = "";
binOptList["-ts"] = "";
binOptList["-V"] = "";
binOptList["-O"] = "";
binOptList["-l"].clear();
binOptList["-d"].clear();
binOptList["-p"].clear();
binOptList["-f"].clear();
binOptList["-E"].clear();
binOptList["-td"].clear();
binOptList["-ts"].clear();
binOptList["-V"].clear();
binOptList["-O"].clear();

int startIdx = findCommandLineOpts(numargs, args, unOptList, binOptList);
parseOpts(unOptList, binOptList);
Expand Down
Loading