1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-18 00:54:19 +00:00

misc optimisations

This commit is contained in:
jules 2007-06-17 16:02:59 +00:00
parent 00e469d8ac
commit bfdb48d4bc
53 changed files with 1852 additions and 1877 deletions

View file

@ -62,7 +62,7 @@ static File executableFile;
//==============================================================================
bool juce_isDirectory (const String& fileName)
bool juce_isDirectory (const String& fileName) throw()
{
if (fileName.isEmpty())
return true;
@ -75,7 +75,7 @@ bool juce_isDirectory (const String& fileName)
return false;
}
bool juce_fileExists (const String& fileName, const bool dontCountDirectories)
bool juce_fileExists (const String& fileName, const bool dontCountDirectories) throw()
{
if (fileName.isEmpty())
return false;
@ -88,7 +88,7 @@ bool juce_fileExists (const String& fileName, const bool dontCountDirectories)
return exists;
}
int64 juce_getFileSize (const String& fileName)
int64 juce_getFileSize (const String& fileName) throw()
{
struct stat info;
const int res = stat (fileName.toUTF8(), &info);
@ -102,7 +102,7 @@ int64 juce_getFileSize (const String& fileName)
void juce_getFileTimes (const String& fileName,
int64& modificationTime,
int64& accessTime,
int64& creationTime)
int64& creationTime) throw()
{
modificationTime = 0;
accessTime = 0;
@ -125,7 +125,7 @@ void juce_getFileTimes (const String& fileName,
bool juce_setFileTimes (const String& fileName,
int64 modificationTime,
int64 accessTime,
int64 creationTime)
int64 creationTime) throw()
{
struct utimbuf times;
times.actime = (time_t) (accessTime / 1000);
@ -134,12 +134,12 @@ bool juce_setFileTimes (const String& fileName,
return utime (fileName.toUTF8(), &times) == 0;
}
bool juce_canWriteToFile (const String& fileName)
bool juce_canWriteToFile (const String& fileName) throw()
{
return access (fileName.toUTF8(), W_OK) == 0;
}
bool juce_setFileReadOnly (const String& fileName, bool isReadOnly)
bool juce_setFileReadOnly (const String& fileName, bool isReadOnly) throw()
{
struct stat info;
const int res = stat (fileName.toUTF8(), &info);
@ -157,7 +157,7 @@ bool juce_setFileReadOnly (const String& fileName, bool isReadOnly)
return chmod (fileName.toUTF8(), info.st_mode) == 0;
}
bool juce_deleteFile (const String& fileName)
bool juce_deleteFile (const String& fileName) throw()
{
if (juce_isDirectory (fileName))
return rmdir (fileName.toUTF8()) == 0;
@ -165,7 +165,7 @@ bool juce_deleteFile (const String& fileName)
return remove (fileName.toUTF8()) == 0;
}
bool juce_copyFile (const String& s, const String& d)
bool juce_copyFile (const String& s, const String& d) throw()
{
const File source (s), dest (d);
@ -196,7 +196,7 @@ bool juce_copyFile (const String& s, const String& d)
return ok;
}
bool juce_moveFile (const String& source, const String& dest)
bool juce_moveFile (const String& source, const String& dest) throw()
{
if (rename (source.toUTF8(), dest.toUTF8()) == 0)
return true;
@ -215,12 +215,12 @@ bool juce_moveFile (const String& source, const String& dest)
return false;
}
void juce_createDirectory (const String& fileName)
void juce_createDirectory (const String& fileName) throw()
{
mkdir (fileName.toUTF8(), 0777);
}
void* juce_fileOpen (const String& fileName, bool forWriting)
void* juce_fileOpen (const String& fileName, bool forWriting) throw()
{
const char* mode = "rb";
@ -243,13 +243,13 @@ void* juce_fileOpen (const String& fileName, bool forWriting)
return (void*)fopen (fileName.toUTF8(), mode);
}
void juce_fileClose (void* handle)
void juce_fileClose (void* handle) throw()
{
if (handle != 0)
fclose ((FILE*) handle);
}
int juce_fileRead (void* handle, void* buffer, int size)
int juce_fileRead (void* handle, void* buffer, int size) throw()
{
if (handle != 0)
return fread (buffer, 1, size, (FILE*) handle);
@ -257,7 +257,7 @@ int juce_fileRead (void* handle, void* buffer, int size)
return 0;
}
int juce_fileWrite (void* handle, const void* buffer, int size)
int juce_fileWrite (void* handle, const void* buffer, int size) throw()
{
if (handle != 0)
return fwrite (buffer, 1, size, (FILE*) handle);
@ -265,7 +265,7 @@ int juce_fileWrite (void* handle, const void* buffer, int size)
return 0;
}
int64 juce_fileSetPosition (void* handle, int64 pos)
int64 juce_fileSetPosition (void* handle, int64 pos) throw()
{
if (handle != 0 && fseek ((FILE*) handle, (long) pos, SEEK_SET) == 0)
return pos;
@ -273,7 +273,7 @@ int64 juce_fileSetPosition (void* handle, int64 pos)
return -1;
}
int64 juce_fileGetPosition (void* handle)
int64 juce_fileGetPosition (void* handle) throw()
{
if (handle != 0)
return ftell ((FILE*) handle);
@ -281,13 +281,13 @@ int64 juce_fileGetPosition (void* handle)
return -1;
}
void juce_fileFlush (void* handle)
void juce_fileFlush (void* handle) throw()
{
if (handle != 0)
fflush ((FILE*) handle);
}
const StringArray juce_getFileSystemRoots()
const StringArray juce_getFileSystemRoots() throw()
{
StringArray s;
s.add (T("/"));
@ -295,7 +295,7 @@ const StringArray juce_getFileSystemRoots()
}
const String juce_getVolumeLabel (const String& filenameOnVolume,
int& volumeSerialNumber)
int& volumeSerialNumber) throw()
{
// There is no equivalent on Linux
volumeSerialNumber = 0;
@ -421,7 +421,7 @@ const File File::getSpecialLocation (const SpecialLocationType type)
}
//==============================================================================
void juce_setCurrentExecutableFileName (const String& filename)
void juce_setCurrentExecutableFileName (const String& filename) throw()
{
executableFile = File::getCurrentWorkingDirectory().getChildFile (filename);
}
@ -450,7 +450,7 @@ struct FindFileStruct
DIR* dir;
bool getNextMatch (String& result, bool* const isDir, bool* const isHidden, int64* const fileSize,
Time* const modTime, Time* const creationTime, bool* const isReadOnly)
Time* const modTime, Time* const creationTime, bool* const isReadOnly) throw()
{
const char* const wildcardUTF8 = wildCard.toUTF8();
@ -507,7 +507,7 @@ struct FindFileStruct
// returns 0 on failure
void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResultFile,
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, Time* creationTime, bool* isReadOnly)
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, Time* creationTime, bool* isReadOnly) throw()
{
DIR* d = opendir (directory.toUTF8());
@ -543,7 +543,7 @@ void* juce_findFileStart (const String& directory, const String& wildCard, Strin
}
bool juce_findFileNext (void* handle, String& resultFile,
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, Time* creationTime, bool* isReadOnly)
bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, Time* creationTime, bool* isReadOnly) throw()
{
FindFileStruct* const ff = (FindFileStruct*) handle;
@ -553,7 +553,7 @@ bool juce_findFileNext (void* handle, String& resultFile,
return false;
}
void juce_findFileClose (void* handle)
void juce_findFileClose (void* handle) throw()
{
FindFileStruct* const ff = (FindFileStruct*) handle;
@ -565,7 +565,7 @@ void juce_findFileClose (void* handle)
}
bool juce_launchFile (const String& fileName,
const String& parameters)
const String& parameters) throw()
{
String cmdString (fileName);
cmdString << " " << parameters;

View file

@ -50,7 +50,7 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
int SystemStats::getMACAddresses (int64* addresses, int maxNum)
int SystemStats::getMACAddresses (int64* addresses, int maxNum) throw()
{
// xxx todo
return 0;

View file

@ -57,7 +57,7 @@ static struct _LogicalCpuInfo
} logicalCpuInfo;
//==============================================================================
static juce_noinline unsigned int getCPUIDWord (int* familyModel, int* extFeatures)
static juce_noinline unsigned int getCPUIDWord (int* familyModel, int* extFeatures) throw()
{
unsigned int cpu = 0;
unsigned int ext = 0;
@ -77,7 +77,7 @@ static juce_noinline unsigned int getCPUIDWord (int* familyModel, int* extFeatur
return cpu;
}
void juce_initLogicalCpuInfo()
void juce_initLogicalCpuInfo() throw()
{
int familyModelWord, extFeaturesWord;
int featuresWord = getCPUIDWord (&familyModelWord, &extFeaturesWord);
@ -182,13 +182,13 @@ void juce_initLogicalCpuInfo()
}
//==============================================================================
void Logger::outputDebugString (const String& text)
void Logger::outputDebugString (const String& text) throw()
{
fprintf (stdout, text.toUTF8());
fprintf (stdout, "\n");
}
void Logger::outputDebugPrintf (const tchar* format, ...)
void Logger::outputDebugPrintf (const tchar* format, ...) throw()
{
String text;
va_list args;
@ -197,17 +197,17 @@ void Logger::outputDebugPrintf (const tchar* format, ...)
outputDebugString(text);
}
SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()
SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() throw()
{
return Linux;
}
const String SystemStats::getOperatingSystemName()
const String SystemStats::getOperatingSystemName() throw()
{
return T("Linux");
}
static const String getCpuInfo (const char* key, bool lastOne = false)
static const String getCpuInfo (const char* key, bool lastOne = false) throw()
{
String info;
char buf [256];
@ -243,44 +243,44 @@ static const String getCpuInfo (const char* key, bool lastOne = false)
return info;
}
bool SystemStats::hasMMX()
bool SystemStats::hasMMX() throw()
{
return getCpuInfo ("flags").contains (T("mmx"));
}
bool SystemStats::hasSSE()
bool SystemStats::hasSSE() throw()
{
return getCpuInfo ("flags").contains (T("sse"));
}
bool SystemStats::hasSSE2()
bool SystemStats::hasSSE2() throw()
{
return getCpuInfo ("flags").contains (T("sse2"));
}
bool SystemStats::has3DNow()
bool SystemStats::has3DNow() throw()
{
return getCpuInfo ("flags").contains (T("3dnow"));
}
const String SystemStats::getCpuVendor()
const String SystemStats::getCpuVendor() throw()
{
return getCpuInfo ("vendor_id");
}
int SystemStats::getCpuSpeedInMegaherz()
int SystemStats::getCpuSpeedInMegaherz() throw()
{
const String speed (getCpuInfo ("cpu MHz"));
return (int) (speed.getFloatValue() + 0.5f);
}
bool SystemStats::hasHyperThreading()
bool SystemStats::hasHyperThreading() throw()
{
return logicalCpuInfo.htAvailable;
}
int SystemStats::getMemorySizeInMegabytes()
int SystemStats::getMemorySizeInMegabytes() throw()
{
struct sysinfo sysi;
@ -336,7 +336,7 @@ int64 Time::getHighResolutionTicksPerSecond() throw()
return 1000000;
}
bool Time::setSystemTimeToThisTime() const
bool Time::setSystemTimeToThisTime() const throw()
{
timeval t;
t.tv_sec = millisSinceEpoch % 1000000;
@ -345,7 +345,7 @@ bool Time::setSystemTimeToThisTime() const
return settimeofday (&t, NULL) ? false : true;
}
int SystemStats::getPageSize()
int SystemStats::getPageSize() throw()
{
static int systemPageSize = 0;
@ -355,7 +355,7 @@ int SystemStats::getPageSize()
return systemPageSize;
}
int SystemStats::getNumPhysicalCpus()
int SystemStats::getNumPhysicalCpus() throw()
{
if (logicalCpuInfo.numPackages)
return logicalCpuInfo.numPackages;
@ -363,14 +363,14 @@ int SystemStats::getNumPhysicalCpus()
return getNumLogicalCpus();
}
int SystemStats::getNumLogicalCpus()
int SystemStats::getNumLogicalCpus() throw()
{
const int lastCpu = getCpuInfo ("processor", true).getIntValue();
return lastCpu + 1;
}
uint32 SystemStats::getPhysicalAffinityMask()
uint32 SystemStats::getPhysicalAffinityMask() throw()
{
#if SUPPORT_AFFINITIES
return logicalCpuInfo.physicalAffinityMask;
@ -385,7 +385,7 @@ uint32 SystemStats::getPhysicalAffinityMask()
}
//==============================================================================
void SystemStats::initialiseStats()
void SystemStats::initialiseStats() throw()
{
// Process starts off as root when running suid
Process::lowerPrivilege();

View file

@ -51,7 +51,7 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
void JUCE_API juce_threadEntryPoint (void*);
void* threadEntryProc (void* value)
void* threadEntryProc (void* value) throw()
{
// New threads start off as root when running suid
Process::lowerPrivilege();
@ -60,7 +60,7 @@ void* threadEntryProc (void* value)
return 0;
}
void* juce_createThread (void* userData)
void* juce_createThread (void* userData) throw()
{
pthread_t handle = 0;
@ -73,17 +73,17 @@ void* juce_createThread (void* userData)
return 0;
}
void juce_killThread (void* handle)
void juce_killThread (void* handle) throw()
{
if (handle != 0)
pthread_cancel ((pthread_t)handle);
}
void juce_setCurrentThreadName (const String& /*name*/)
void juce_setCurrentThreadName (const String& /*name*/) throw()
{
}
int Thread::getCurrentThreadId()
int Thread::getCurrentThreadId() throw()
{
return (int) pthread_self();
}
@ -104,7 +104,7 @@ int Thread::getCurrentThreadId()
// priority 1 to 10 where 5=normal, 1=low. If the handle is 0, sets the
// priority of the current thread
void juce_setThreadPriority (void* handle, int priority)
void juce_setThreadPriority (void* handle, int priority) throw()
{
struct sched_param param;
int policy, maxp, minp, pri;
@ -162,12 +162,12 @@ void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask)
#endif
}
void Thread::yield()
void Thread::yield() throw()
{
sched_yield();
}
void Thread::sleep (int millisecs)
void Thread::sleep (int millisecs) throw()
{
struct timespec time;
time.tv_sec = millisecs / 1000;

View file

@ -151,7 +151,7 @@ static bool untrapErrors()
//==============================================================================
static bool isActiveApplication = false;
bool Process::isForegroundProcess()
bool Process::isForegroundProcess() throw()
{
return isActiveApplication;
}
@ -2541,7 +2541,7 @@ void Desktop::setMousePosition (int x, int y)
}
//==============================================================================
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY)
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw()
{
Window root = RootWindow (display, DefaultScreen (display));
const unsigned int imageW = image.getWidth();
@ -2609,13 +2609,13 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot
return result;
}
void juce_deleteMouseCursor (void* cursorHandle, bool)
void juce_deleteMouseCursor (void* const cursorHandle, const bool) throw()
{
if (cursorHandle != None)
XFreeCursor (display, (Cursor)cursorHandle);
XFreeCursor (display, (Cursor) cursorHandle);
}
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type)
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw()
{
unsigned int shape;