[aseprite] 41/196: Cache name and path in RecentFileItem

Tobias Hansen thansen at moszumanska.debian.org
Wed Apr 20 18:49:59 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit f391be68241c0705224d490f649e6253e5b1c680
Author: David Capello <davidcapello at gmail.com>
Date:   Fri Mar 4 17:30:12 2016 -0300

    Cache name and path in RecentFileItem
    
    This is to avoid calling base.:get_file_name/path()
    on each onPaint/SizeHint()
---
 src/app/ui/recent_listbox.cpp | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/app/ui/recent_listbox.cpp b/src/app/ui/recent_listbox.cpp
index a9e913f..5826f62 100644
--- a/src/app/ui/recent_listbox.cpp
+++ b/src/app/ui/recent_listbox.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  David Capello
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License version 2 as
@@ -40,7 +40,9 @@ using namespace skin;
 class RecentFileItem : public LinkLabel {
 public:
   RecentFileItem(const std::string& file)
-    : LinkLabel(file) {
+    : LinkLabel(file)
+    , m_name(base::get_file_name(file))
+    , m_path(base::get_file_path(file)) {
   }
 
 protected:
@@ -49,8 +51,8 @@ protected:
     Style* style = theme->styles.recentFile();
     Style* styleDetail = theme->styles.recentFileDetail();
     Style::State state;
-    gfx::Size sz1 = style->sizeHint(name().c_str(), state);
-    gfx::Size sz2 = styleDetail->sizeHint(path().c_str(), state);
+    gfx::Size sz1 = style->sizeHint(m_name.c_str(), state);
+    gfx::Size sz2 = styleDetail->sizeHint(m_path.c_str(), state);
     ev.setSizeHint(gfx::Size(sz1.w+sz2.w, MAX(sz1.h, sz2.h)));
   }
 
@@ -66,14 +68,13 @@ protected:
     if (isSelected()) state += Style::active();
     if (parent()->hasCapture()) state += Style::clicked();
 
-    std::string name = this->name();
-    style->paint(g, bounds, name.c_str(), state);
+    style->paint(g, bounds, m_name.c_str(), state);
 
-    gfx::Size textSize = style->sizeHint(name.c_str(), state);
+    gfx::Size textSize = style->sizeHint(m_name.c_str(), state);
     gfx::Rect detailsBounds(
       bounds.x+textSize.w, bounds.y,
       bounds.w-textSize.w, bounds.h);
-    styleDetail->paint(g, detailsBounds, path().c_str(), state);
+    styleDetail->paint(g, detailsBounds, m_path.c_str(), state);
   }
 
   void onClick() override {
@@ -81,8 +82,8 @@ protected:
   }
 
 private:
-  std::string name() const { return base::get_file_name(text()); }
-  std::string path() const { return base::get_file_path(text()); }
+  std::string m_name;
+  std::string m_path;
 };
 
 //////////////////////////////////////////////////////////////////////

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list