[ai] Memory Optimizations
This commit is contained in:
@@ -405,11 +405,11 @@ DirectoryNode *DirectoryNode::advanceToMP3(const String &songName)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use static buffer for case conversion and comparison
|
||||
// Use static buffer for comparison without allocation
|
||||
buildFullPath(mp3Files[i], buffer, buffer_size);
|
||||
String f = String(buffer);
|
||||
f.toLowerCase();
|
||||
if (f.endsWith(lowTarget))
|
||||
size_t bufLen = strlen(buffer);
|
||||
size_t targetLen = lowTarget.length();
|
||||
if (bufLen >= targetLen && strcasecmp(buffer + bufLen - targetLen, lowTarget.c_str()) == 0)
|
||||
{
|
||||
setCurrentPlaying(mp3Files[i]);
|
||||
return this;
|
||||
@@ -450,9 +450,11 @@ DirectoryNode *DirectoryNode::advanceToMP3(const String &songName)
|
||||
}
|
||||
else
|
||||
{
|
||||
String f = subdir->mp3Files[i];
|
||||
f.toLowerCase();
|
||||
if (f.endsWith(lowTarget))
|
||||
// Check suffix case-insensitively without creating new Strings
|
||||
const String& fName = subdir->mp3Files[i];
|
||||
size_t fLen = fName.length();
|
||||
size_t targetLen = lowTarget.length();
|
||||
if (fLen >= targetLen && strcasecmp(fName.c_str() + fLen - targetLen, lowTarget.c_str()) == 0)
|
||||
{
|
||||
subdir->setCurrentPlaying(subdir->mp3Files[i]);
|
||||
return subdir;
|
||||
|
||||
Reference in New Issue
Block a user