Skip to content

Commit

Permalink
Very minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulp committed Oct 23, 2024
1 parent 6261c16 commit 3e291b2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 3 additions & 2 deletions xLights/SeqFileUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,9 @@ void xLightsFrame::OpenSequence(const wxString& passed_filename, ConvertLogDialo
}

// if fseq had media update xml
if (!CurrentSeqXmlFile->HasAudioMedia() && FileExists(media_file) && wxFileName(media_file).IsFileReadable()) {
CurrentSeqXmlFile->SetMediaFile(GetShowDirectory(), media_file.GetFullPath(), true);
wxString mfFP = media_file.GetFullPath();
if (!mfFP.empty() && !CurrentSeqXmlFile->HasAudioMedia() && FileExists(mfFP) && media_file.IsFileReadable()) {
CurrentSeqXmlFile->SetMediaFile(GetShowDirectory(), mfFP, true);
int length_ms = CurrentSeqXmlFile->GetMedia()->LengthMS();
CurrentSeqXmlFile->SetSequenceDurationMS(length_ms);
playAnimation = false;
Expand Down
4 changes: 2 additions & 2 deletions xLights/outputs/ControllerEthernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void ControllerEthernet::SetIP(const std::string& ip) {
void ControllerEthernet::PostSetActive()
{
std::unique_lock<std::shared_mutex> lock(_resolveMutex);
if (IsActive() && _ip != "" && _resolvedIp == "") {
if (IsActive() && !_ip.empty() && _resolvedIp.empty()) {
_resolvedIp = ip_utils::ResolveIP(_ip);
lock.unlock();
std::shared_lock<std::shared_mutex> lock(_resolveMutex);
Expand All @@ -249,7 +249,7 @@ void ControllerEthernet::PostSetActive()
}
std::string ControllerEthernet::GetResolvedIP(bool forceResolve) const {
std::shared_lock<std::shared_mutex> lock(_resolveMutex);
if (_resolvedIp == "" && _ip != "" && forceResolve) {
if (_resolvedIp.empty() && !_ip.empty() && forceResolve) {
return ip_utils::ResolveIP(_ip);
}
return _resolvedIp;
Expand Down
4 changes: 1 addition & 3 deletions xLights/utils/ip_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ namespace ip_utils
virtual void Process() {
struct addrinfo hints, *res, *result;
int errcode;
char addrstr[100];
void *ptr;

memset (&hints, 0, sizeof (hints));
Expand All @@ -160,8 +159,7 @@ namespace ip_utils
} else {
res = result;
while (res) {
inet_ntop(res->ai_family, res->ai_addr->sa_data, addrstr, 100);

char addrstr[100] = {0};
switch (res->ai_family) {
case AF_INET:
ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
Expand Down

0 comments on commit 3e291b2

Please sign in to comment.