[PATCH 2/3] drm: replace the 'for' condition with outside defined variable
Daniel Vetter
daniel at ffwll.ch
Tue Mar 17 01:40:13 PDT 2015
On Tue, Mar 17, 2015 at 03:30:27PM +0800, John Hunter wrote:
> use outdise defined variable can reduce the recaculate of the
> count of planes, crtcs and connectors.
>
> Signed-off-by: John Hunter <zhjwpku at gmail.com>
Hm, what's the benefit you see for this change? The lines aren't too long
yet and we don't reuse the expression, so imo code readability isn't
improved.
-Daniel
> ---
> drivers/gpu/drm/drm_atomic_helper.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 39369ee..20376e6 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1301,8 +1301,11 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
> struct drm_atomic_state *state)
> {
> int i;
> + int nconnectors = dev->mode_config.num_connector;
> + int ncrtcs = dev->mode_config.num_crtc;
> + int nplanes = dev->mode_config.num_total_plane;
>
> - for (i = 0; i < dev->mode_config.num_connector; i++) {
> + for (i = 0; i < nconnectors; i++) {
> struct drm_connector *connector = state->connectors[i];
>
> if (!connector)
> @@ -1313,7 +1316,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
> connector->state->state = NULL;
> }
>
> - for (i = 0; i < dev->mode_config.num_crtc; i++) {
> + for (i = 0; i < ncrtcs; i++) {
> struct drm_crtc *crtc = state->crtcs[i];
>
> if (!crtc)
> @@ -1324,7 +1327,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
> crtc->state->state = NULL;
> }
>
> - for (i = 0; i < dev->mode_config.num_total_plane; i++) {
> + for (i = 0; i < nplanes; i++) {
> struct drm_plane *plane = state->planes[i];
>
> if (!plane)
> --
> 1.9.1
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
More information about the dri-devel
mailing list