Closed (outdated)
Project:
Flexifilter
Version:
6.x-1.x-dev
Component:
Code - Misc
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
12 Nov 2008 at 13:31 UTC
Updated:
24 Sep 2020 at 20:27 UTC
Jump to comment: Most recent
Comments
Comment #1
avpadernoAnother example is
_flexifilter_push_conf()(flexifilter.components.inc), where the foreach-loop can be replaced with a call toarray_merge().Comment #2
avpadernoAlso in
flexifilter_get_component_list()the following code is used:Generally speaking, if I want to be sure an array contains some values I use the following code:
In this way, the keys which aren't
$valuesbut are in$default_valueswill take the default values, without the need to check every keys of the array.In the specific, the foreach loop would become:
Comment #3
avpadernoIn
flexifilter_get_filter_by_delta()(flexifilter.module), the following codecan be simplified in
Comment #4
steven jones commentedGood points, but, provide a patch please.
Comment #5
avpadernoI am not sure if that could be helpful, as the maintainer is going to update the module with a 6.x-1.1 version.
For now, these are just suggestions; when I see the new release, I will eventually make a patch.
Comment #6
avpadernoIn
_flexifilter_filter_from_db_row()there is the following lines of codewhich can be rewritten like
as PHP, in every contexts where a boolean value is expected, consider any value different from 0 like TRUE.
Therefore, the following code
could also be rewritten like
if
$rowdoesn't contain any values apart the ones showed there.Comment #7
avpadernoflexifilter_get_number_enabled_filters()use the following code:It can be changed in:
Comment #8
avpadernoThe code of
flexifilter_get_unused_delta()is the following:It can simplified a lot rewriting it like:
There is no reason to build an array of 128 items which are first set to TRUE, and then (some of them) to FALSE, when the function returns a single value. This means to use 3 loops against 1 that is really needed.
Comment #9
avpadernoIn
flexifilter_filter_edit_components_data()there is the following code:It can better rewritten like:
Comment #10
avpadernoI am closing this issue since it's for a Drupal version that isn't supported.