Skip to content

Commit

Permalink
WebKitBrowser: use local variable children to iterate over (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul authored Feb 22, 2024
1 parent 54ce4ce commit a350037
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions WebKitBrowser/WebKitBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ namespace WebKitBrowser {

result = _main.Resident();

_children.Reset();
children.Reset();

while (_children.Next() == true) {
result += _children.Current().Resident();
while (children.Next() == true) {
result += children.Current().Resident();
}
}

Expand All @@ -465,10 +465,10 @@ namespace WebKitBrowser {

result = _main.Allocated();

_children.Reset();
children.Reset();

while (_children.Next() == true) {
result += _children.Current().Allocated();
while (children.Next() == true) {
result += children.Current().Allocated();
}
}

Expand All @@ -490,10 +490,10 @@ namespace WebKitBrowser {

result = _main.Shared();

_children.Reset();
children.Reset();

while (_children.Next() == true) {
result += _children.Current().Shared();
while (children.Next() == true) {
result += children.Current().Shared();
}
}

Expand All @@ -504,9 +504,10 @@ namespace WebKitBrowser {
// Refresh the children list !!!
_adminLock.Lock();
_children = Core::ProcessInfo::Iterator(_main.Id());
uint32_t nbrchildren = _children.Count();
_adminLock.Unlock();

return ((_startTime == TimePoint::min()) || (_main.IsActive() == true) ? 1 : 0) + _children.Count();
return ((_startTime == TimePoint::min()) || (_main.IsActive() == true) ? 1 : 0) + nbrchildren;
}
bool IsOperational() const override
{
Expand All @@ -527,23 +528,23 @@ namespace WebKitBrowser {
_adminLock.Unlock();

//!< If there are less children than in the the mandatoryProcesses struct, we are done and return false.
if (_children.Count() >= RequiredChildren) {
if (children.Count() >= RequiredChildren) {

_children.Reset();
children.Reset();

//!< loop over all child processes as long as we are operational.
while ((requiredProcesses != 0) && (true == _children.Next())) {
while ((requiredProcesses != 0) && (true == children.Next())) {

uint8_t count(0);
string name(_children.Current().Name());
string name(children.Current().Name());

while ((count < RequiredChildren) && (name != mandatoryProcesses[count])) {
++count;
}

//<! this is a mandatory process and if its still active reset its bit in requiredProcesses.
// If not we are not completely operational.
if ((count < RequiredChildren) && (_children.Current().IsActive() == true)) {
if ((count < RequiredChildren) && (children.Current().IsActive() == true)) {
requiredProcesses &= (~(1 << count));
}
}
Expand Down

0 comments on commit a350037

Please sign in to comment.