1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Minor clean-ups.

This commit is contained in:
jules 2013-01-05 20:07:22 +00:00
parent ddb6b969ea
commit e543949bda
28 changed files with 109 additions and 117 deletions

View file

@ -479,7 +479,7 @@ File LibraryModule::getLocalFolderFor (Project& project) const
{
if (project.shouldCopyModuleFilesLocally (getID()).getValue())
return project.getGeneratedCodeFolder().getChildFile ("modules").getChildFile (getID());
else
return moduleFolder;
}

View file

@ -517,7 +517,7 @@ String Project::Item::getFilePath() const
{
if (isFile())
return state [Ids::file].toString();
else
return String::empty;
}
@ -525,7 +525,7 @@ File Project::Item::getFile() const
{
if (isFile())
return project.resolveFilename (state [Ids::file].toString());
else
return File::nonexistent;
}
@ -675,7 +675,7 @@ struct ItemSorterWithGroupsAtStart
if (firstIsGroup == secondIsGroup)
return first [Ids::name].toString().compareIgnoreCase (second [Ids::name].toString());
else
return firstIsGroup ? -1 : 1;
}
};

View file

@ -193,7 +193,7 @@ namespace CodeHelpers
{
if (includePath.startsWithChar ('<') || includePath.startsWithChar ('"'))
return "#include " + includePath;
else
return "#include \"" + includePath + "\"";
}

View file

@ -76,7 +76,7 @@ namespace FileHelpers
if (file.exists())
return file.replaceWithData (data, numBytes);
else
return file.appendData (data, numBytes);
}

View file

@ -442,7 +442,7 @@ Result JucerDocument::saveDocument (const File& file)
if (ok)
return Result::ok();
else
return Result::fail (TRANS("Couldn't write to the file."));
}

View file

@ -148,7 +148,7 @@ const String quotedString (const String& s)
if (CharPointer_ASCII::isValidString (s.toUTF8(), std::numeric_limits<int>::max()))
return addEscapeChars (s).quoted();
else
return "CharPointer_UTF8 (" + addEscapeChars (s).quoted() + ")";
}

View file

@ -900,7 +900,7 @@ public:
{
if (internal->inputDevice != 0)
return internal->inputDevice->inChanNames;
else
return internal->inChanNames;
}

View file

@ -166,7 +166,7 @@ public:
if (type == 0)
return noDisc;
else
return readOnlyDiskPresent;
}

View file

@ -165,7 +165,7 @@ double AudioTransportSource::getCurrentPosition() const
{
if (sampleRate > 0.0)
return getNextReadPosition() / sampleRate;
else
return 0.0;
}

View file

@ -1596,7 +1596,7 @@ bool AudioUnitPluginFormat::doesPluginStillExist (const PluginDescription& desc)
{
if (desc.fileOrIdentifier.startsWithIgnoreCase (AudioUnitFormatHelpers::auIdentifierPrefix))
return fileMightContainThisPluginType (desc.fileOrIdentifier);
else
return File (desc.fileOrIdentifier).exists();
}

View file

@ -139,7 +139,7 @@ public:
if (isPositiveAndBelow (rangeIndex, getNumRanges()))
return Range<Type> (values.getUnchecked (rangeIndex << 1),
values.getUnchecked ((rangeIndex << 1) + 1));
else
return Range<Type>();
}

View file

@ -286,9 +286,10 @@ String File::getPathUpToLastSlash() const
if (lastSlash > 0)
return fullPath.substring (0, lastSlash);
else if (lastSlash == 0)
if (lastSlash == 0)
return separatorString;
else
return fullPath;
}
@ -312,7 +313,7 @@ String File::getFileNameWithoutExtension() const
if (lastDot > lastSlash)
return fullPath.substring (lastSlash, lastDot);
else
return fullPath.substring (lastSlash);
}

View file

@ -439,7 +439,7 @@ struct Expression::Helpers
{
if (input->getOperatorPrecedence() > 0)
return "-(" + input->toString() + ")";
else
return "-" + input->toString();
}
@ -492,7 +492,7 @@ struct Expression::Helpers
if (input == left)
return new Add (newDest, right->clone());
else
return new Subtract (left->clone(), newDest);
}
@ -545,7 +545,7 @@ struct Expression::Helpers
if (input == left)
return new Multiply (newDest, right->clone());
else
return new Divide (left->clone(), newDest);
}

View file

@ -480,7 +480,7 @@ bool File::isOnHardDisk() const
if (fullPath.toLowerCase()[0] <= 'b' && fullPath[1] == ':')
return n != DRIVE_REMOVABLE;
else
return n != DRIVE_CDROM && n != DRIVE_REMOTE;
}

View file

@ -223,7 +223,7 @@ String URL::toString (const bool includeGetParameters) const
{
if (includeGetParameters && parameterNames.size() > 0)
return url + "?" + URLHelpers::getMangledParameters (*this);
else
return url;
}

View file

@ -77,8 +77,8 @@ int SubregionStream::read (void* destBuffer, int maxBytesToRead)
bool SubregionStream::isExhausted()
{
if (lengthOfSourceStream >= 0)
return (getPosition() >= lengthOfSourceStream) || source->isExhausted();
else
if (lengthOfSourceStream >= 0 && getPosition() >= lengthOfSourceStream)
return true;
return source->isExhausted();
}

View file

@ -1567,7 +1567,8 @@ String String::trim() const
if (trimmedEnd <= start)
return empty;
else if (text < start || trimmedEnd < end)
if (text < start || trimmedEnd < end)
return String (start, trimmedEnd);
}
@ -1921,14 +1922,12 @@ String String::createStringFromData (const void* const data_, const int size)
const uint8* const data = static_cast <const uint8*> (data_);
if (size <= 0 || data == nullptr)
{
return empty;
}
else if (size == 1)
{
if (size == 1)
return charToString ((juce_wchar) data[0]);
}
else if ((data[0] == (uint8) CharPointer_UTF16::byteOrderMarkBE1 && data[1] == (uint8) CharPointer_UTF16::byteOrderMarkBE2)
if ((data[0] == (uint8) CharPointer_UTF16::byteOrderMarkBE1 && data[1] == (uint8) CharPointer_UTF16::byteOrderMarkBE2)
|| (data[0] == (uint8) CharPointer_UTF16::byteOrderMarkLE1 && data[1] == (uint8) CharPointer_UTF16::byteOrderMarkLE2))
{
const bool bigEndian = (data[0] == (uint8) CharPointer_UTF16::byteOrderMarkBE1);
@ -1952,8 +1951,7 @@ String String::createStringFromData (const void* const data_, const int size)
builder.write (0);
return builder.result;
}
else
{
const uint8* start = data;
const uint8* end = data + size;
@ -1965,7 +1963,6 @@ String String::createStringFromData (const void* const data_, const int size)
return String (CharPointer_UTF8 ((const char*) start),
CharPointer_UTF8 ((const char*) end));
}
}
//==============================================================================

View file

@ -841,7 +841,7 @@ String XmlDocument::getParameterEntity (const String& entity)
if (ent.equalsIgnoreCase ("system"))
return getFileContents (tokenisedDTD [i + 2].trimCharactersAtEnd (">"));
else
return ent.trim().unquoted();
}
}

View file

@ -171,7 +171,7 @@ bool PropertiesFile::save()
if (options.storageFormat == storeAsXML)
return saveAsXml();
else
return saveAsBinary();
}

View file

@ -92,7 +92,7 @@ public:
// to keep everything running smoothly..
if ((++totalEventCount & 1) != 0)
return dispatchNextXEvent() || dispatchNextInternalMessage();
else
return dispatchNextInternalMessage() || dispatchNextXEvent();
}

View file

@ -189,7 +189,7 @@ Rectangle<float> DrawableShape::getDrawableBounds() const
{
if (isStrokeVisible())
return strokePath.getBounds();
else
return path.getBounds();
}

View file

@ -1026,7 +1026,7 @@ private:
return Colour ((uint8) (hex [0] * 0x11),
(uint8) (hex [1] * 0x11),
(uint8) (hex [2] * 0x11));
else
return Colour ((uint8) ((hex [0] << 4) + hex [1]),
(uint8) ((hex [2] << 4) + hex [3]),
(uint8) ((hex [4] << 4) + hex [5]));

View file

@ -1616,11 +1616,10 @@ private:
static NSDragOperation draggingUpdated (id self, SEL, id <NSDraggingInfo> sender)
{
NSViewComponentPeer* const owner = getOwner (self);
if (owner != nullptr && owner->sendDragCallback (0, sender))
if (NSViewComponentPeer* const owner = getOwner (self))
if (owner->sendDragCallback (0, sender))
return NSDragOperationCopy | NSDragOperationMove | NSDragOperationGeneric;
else
return NSDragOperationNone;
}

View file

@ -2137,7 +2137,7 @@ private:
{
if (MessageManager::getInstance()->currentThreadHasLockedMessageManager())
return callback (userData);
else
return MessageManager::getInstance()->callFunctionOnMessageThread (callback, userData);
}

View file

@ -109,15 +109,11 @@ public:
float getPositionOfValue (const double value) const
{
if (isHorizontal() || isVertical())
{
return getLinearSliderPos (value);
}
else
{
jassertfalse; // not a valid call on a slider that doesn't work linearly!
return 0.0f;
}
}
void setRange (const double newMin, const double newMax, const double newInt)
{
@ -684,7 +680,8 @@ public:
if (normalPosDistance >= minPosDistance && maxPosDistance >= minPosDistance)
return 1;
else if (normalPosDistance >= maxPosDistance)
if (normalPosDistance >= maxPosDistance)
return 2;
}
@ -1489,7 +1486,7 @@ String Slider::getTextFromValue (double v)
{
if (getNumDecimalPlacesToDisplay() > 0)
return String (v, getNumDecimalPlacesToDisplay()) + getTextValueSuffix();
else
return String (roundToInt (v)) + getTextValueSuffix();
}

View file

@ -269,12 +269,9 @@ void Toolbar::clear()
ToolbarItemComponent* Toolbar::createItem (ToolbarItemFactory& factory, const int itemId)
{
if (itemId == ToolbarItemFactory::separatorBarId)
return new Spacer (itemId, 0.1f, true);
else if (itemId == ToolbarItemFactory::spacerId)
return new Spacer (itemId, 0.5f, false);
else if (itemId == ToolbarItemFactory::flexibleSpacerId)
return new Spacer (itemId, 0, false);
if (itemId == ToolbarItemFactory::separatorBarId) return new Spacer (itemId, 0.1f, true);
if (itemId == ToolbarItemFactory::spacerId) return new Spacer (itemId, 0.5f, false);
if (itemId == ToolbarItemFactory::flexibleSpacerId) return new Spacer (itemId, 0.0f, false);
return factory.createItem (itemId);
}
@ -336,8 +333,10 @@ int Toolbar::getNumItems() const noexcept
int Toolbar::getItemId (const int itemIndex) const noexcept
{
ToolbarItemComponent* const tc = getItemComponent (itemIndex);
return tc != nullptr ? tc->getItemId() : 0;
if (ToolbarItemComponent* const tc = getItemComponent (itemIndex))
return tc->getItemId();
return 0;
}
ToolbarItemComponent* Toolbar::getItemComponent (const int itemIndex) const noexcept
@ -350,16 +349,17 @@ ToolbarItemComponent* Toolbar::getNextActiveComponent (int index, const int delt
for (;;)
{
index += delta;
ToolbarItemComponent* const tc = getItemComponent (index);
if (tc == nullptr)
break;
if (ToolbarItemComponent* const tc = getItemComponent (index))
{
if (tc->isActive)
return tc;
}
else
{
return nullptr;
}
}
}
void Toolbar::setStyle (const ToolbarItemStyle& newStyle)

View file

@ -1222,7 +1222,7 @@ bool TreeViewItem::isOpen() const noexcept
{
if (openness == opennessDefault)
return ownerView != nullptr && ownerView->defaultOpenness;
else
return openness == opennessOpen;
}

View file

@ -158,11 +158,9 @@ public:
static LRESULT CALLBACK hookedWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
Pimpl* const p = getPimpl (hwnd);
if (p != nullptr)
if (Pimpl* const p = getPimpl (hwnd))
return p->windowProc (hwnd, message, wParam, lParam);
else
return DefWindowProcW (hwnd, message, wParam, lParam);
}