Minor update: code compacting

This commit is contained in:
2022-07-22 11:56:19 +02:00
parent fd3738567a
commit 7dfdfdb4ce
10 changed files with 129 additions and 248 deletions

View File

@@ -279,17 +279,14 @@ bool CLiteProtocol::AppendCommandStr( char * pString, int &pLength )
Start = 0;
// Look for other markers
while (Pos < pLength)
{
while (Pos < pLength) {
// Check if start character
if (pString[Pos] == StartChar)
{
if (pString[Pos] == StartChar) {
// Mark start point
Start = Pos;
}
// Check if end character with valid start
else if ((pString[Pos] == EndChar) && (Start < pLength))
{
else if ((pString[Pos] == EndChar) && (Start < pLength)) {
// Mark end and continue
End = Pos+1;
break;
@@ -300,8 +297,7 @@ bool CLiteProtocol::AppendCommandStr( char * pString, int &pLength )
};
// Check if anything available
if (Start < pLength)
{
if (Start < pLength) {
// Calculate length
newLen = End - Start;
@@ -347,8 +343,7 @@ bool CLiteProtocol::AppendParam( const char * pString, const int pLength )
int StringLen;
// Check if valid
if (!pLength || (!pString && (pLength == -1)))
{
if (!pLength || (!pString && (pLength == -1))) {
// Increase string length if required
StringLen = 0;
IncCommandStr( Length + 1 );
@@ -357,8 +352,7 @@ bool CLiteProtocol::AppendParam( const char * pString, const int pLength )
CommandStr[CurrPos+StringLen] = Separator;
Length += 1; // Allow for separator character
}
else
{
else {
// Increase string length if required
StringLen = (pLength < 0)? strlen(pString) : pLength;
IncCommandStr( Length + StringLen+1 );
@@ -501,8 +495,7 @@ char const * CLiteProtocol::GetParam( char ** pString, int * pLength )
char * Mark = NULL;
// Check if valid parameter no
if (!Verified)
{
if (!Verified) {
if (pString) *pString = NULL;
if (pLength) pLength = 0;
return NULL;
@@ -529,8 +522,7 @@ bool CLiteProtocol::CreateCommand( char const * From, char const * To, char cons
return false;
// Insert Parameters in correct order
if (!AppendParam( From ) || !AppendParam( To ) || !AppendParam( Command ))
{
if (!AppendParam( From ) || !AppendParam( To ) || !AppendParam( Command )) {
ClearCommandStr();
return false;
};