Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.

Logic simplifications #1229

Closed
wants to merge 3 commits into from
Closed

Logic simplifications #1229

wants to merge 3 commits into from

Conversation

stilez
Copy link
Contributor

@stilez stilez commented Jan 14, 2016

  1. Nested IF statements can be combined
  2. Add/remove shellcmd contains logic that only needs to run if the early shellcmd array does/doesn't exist
  3. Logs should be non-vague ("...added/removed a shellcmd" is better if it states the command added/removed, and for removal, clarify it removed an existing command)

1) Nested IF statements can be combined
2) Add/remove shellcmd contains logic that only needs to run if the early shellcmd array does/doesn't exist
3) Logs should be non-vague ("...added/removed a shellcmd" is better if it states the command added/removed, and for removal, clarify it removed an existing command)
}
} else {
$a_earlyshellcmd = array();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way the code was changed, this line (and thus the whole "else") is no longer necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely not. The one below, yes but this one adds an item to earlyshellcmd if nothing is found, and will therefore always need the array created if it didn't exist, since that's the most obvious way for !$found to be true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not need to be explicitly created as an array in that case. It will be turned into an array during the assignment with []. The only reason it had to be explicitly declared was to make foreach happy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that's something new to me. Did not realise that $x[] = ... would implicitly create/recreate $x as an array if it wasn't one or didn't exist

@jim-p
Copy link
Contributor

jim-p commented Jan 17, 2016

Somehow I overlooked that this was done against the old pfsense-packages repo, can you resubmit this against our freebsd-ports repo for the 2.3 copy of the package instead? I'd rather not make any more changes to the 2.2.x version of the package unless they're necessary.

stilez added a commit to stilez/pfsense-FreeBSD-ports-stilez-working that referenced this pull request Jan 18, 2016
1) Nested IF statements can be combined
 2) Add/remove shellcmd contains logic that only needs to run if the early shellcmd array does/doesn't exist
 3) Logs should be non-vague ("...added/removed a shellcmd" is better if it states the command added/removed, and for removal, clarify it removed an existing command)

Resubmit of pfsense/pfsense-packages#1229 submitted against the old 2.2 repo as requested
@stilez
Copy link
Contributor Author

stilez commented Jan 18, 2016

@jim-p Against the master or devel branch? (And will it always be the same branch I should submit against?)

@rbgarga
Copy link
Member

rbgarga commented Jan 18, 2016

@stilez against devel please. master branch is a read-only copy of FreeBSD's repo

stilez added a commit to stilez/pfsense-FreeBSD-ports-stilez-working that referenced this pull request Jan 18, 2016
1) Nested IF statements can be combined
2) Add/remove shellcmd contains logic that only needs to run if the early shellcmd array does/doesn't exist
3) Logs should be non-vague ("...added/removed a shellcmd" is better if it states the command added/removed, and for removal, clarify it removed an existing command)

Resubmitted as originally against old pfsense-packages, see pfsense/pfsense-packages#1229
@stilez
Copy link
Contributor Author

stilez commented Jan 18, 2016

Resubmitted, see pfsense/FreeBSD-ports#47

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants