[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r9644: Minor optimizations and remov
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r9644: Minor optimizations and removal of unused functions. |
Date: |
Tue, 26 Aug 2008 15:31:15 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9644
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2008-08-26 15:31:15 +0200
message:
Minor optimizations and removal of unused functions.
modified:
libcore/movie_root.cpp
libcore/movie_root.h
libcore/sprite_instance.h
libcore/swf/PlaceObject2Tag.cpp
libcore/swf/PlaceObject2Tag.h
------------------------------------------------------------
revno: 9642.2.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-26 13:10:17 +0200
message:
Use auto_ptr instead of deleting at end of scope.
modified:
libcore/movie_root.cpp
------------------------------------------------------------
revno: 9642.2.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-26 13:12:39 +0200
message:
Avoid excessive calls to containers' size() member in dtor.
modified:
libcore/swf/PlaceObject2Tag.cpp
libcore/swf/PlaceObject2Tag.h
------------------------------------------------------------
revno: 9642.2.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-26 15:30:20 +0200
message:
Drop unused members in movie_root and sprite_instance.
modified:
libcore/movie_root.cpp
libcore/movie_root.h
libcore/sprite_instance.h
libcore/swf/PlaceObject2Tag.cpp
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2008-08-21 10:06:20 +0000
+++ b/libcore/movie_root.cpp 2008-08-26 13:30:20 +0000
@@ -102,9 +102,6 @@
m_mouse_x(0),
m_mouse_y(0),
m_mouse_buttons(0),
- m_on_event_xmlsocket_ondata_called(false),
- m_on_event_xmlsocket_onxml_called(false),
- m_on_event_load_progress_called(false),
_lastTimerId(0),
m_active_input_text(NULL),
m_time_remainder(0.0f),
@@ -315,7 +312,7 @@
if ( oldDepth < character::staticDepthOffset ) // should include
_level0 !
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("%s.swapDepth(%d): movie has a depth (%d) below
static depth zone (%d), won't swap it's depth"),
+ log_aserror(_("%s.swapDepth(%d): movie has a depth (%d) below
static depth zone (%d), won't swap its depth"),
movie->getTarget(), depth, oldDepth,
character::staticDepthOffset);
);
return;
@@ -324,7 +321,7 @@
if ( oldDepth >= 0 )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("%s.swapDepth(%d): movie has a depth (%d) below
static depth zone (%d), won't swap it's depth"),
+ log_aserror(_("%s.swapDepth(%d): movie has a depth (%d) below
static depth zone (%d), won't swap its depth"),
movie->getTarget(), depth, oldDepth,
character::staticDepthOffset);
);
return;
@@ -599,7 +596,7 @@
}
else
{
- log_error("gnash::notify_key_event(): _global.Key doesn't
exist, or isn't the expected built-in\n");
+ log_error("gnash::notify_key_event(): _global.Key doesn't
exist, or isn't the expected built-in");
}
return _keyobject.get();
@@ -700,9 +697,7 @@
if (ms->m_mouse_button_state_last == mouse_button_state::DOWN)
{
// Mouse button was down.
-
// TODO: Handle trackAsMenu dragOver
-
// Handle onDragOut, onDragOver
if (ms->m_mouse_inside_entity_last == false)
{
@@ -1389,7 +1384,8 @@
boost::intrusive_ptr<character> entity (
m_mouse_button_state.m_active_entity );
if ( ! entity.get() ) {
return false;
- }else {
+ }
+ else {
return true;
}
}
@@ -1477,7 +1473,9 @@
// movie size
movie_definition* md = _rootMovie->get_movie_definition();
- log_debug("Going to or from scaleMode=noScale. Viewport:%dx%d
Def:%dx%d", m_viewport_width, m_viewport_height, md->get_width_pixels(),
md->get_height_pixels());
+ log_debug("Going to or from scaleMode=noScale. Viewport:%dx%d
Def:%dx%d",
+ m_viewport_width, m_viewport_height,
+ md->get_width_pixels(), md->get_height_pixels());
if ( m_viewport_width != md->get_width_pixels()
|| m_viewport_height != md->get_height_pixels() )
@@ -1564,7 +1562,8 @@
bool actionsToProcess = !q.empty();
if ( actionsToProcess )
{
- log_debug(" Processing %d actions in priority queue %d (call
%u)", q.size(), lvl, calls);
+ log_debug(" Processing %d actions in priority queue %d (call
%u)",
+ q.size(), lvl, calls);
}
#endif
@@ -1573,16 +1572,17 @@
// and a final call to .clear()
while ( ! q.empty() )
{
- ExecutableCode* code = q.front();
+ std::auto_ptr<ExecutableCode> code(q.front());
q.pop_front();
code->execute();
- delete code;
int minLevel = minPopulatedPriorityQueue();
if ( minLevel < lvl )
{
#ifdef GNASH_DEBUG
- log_debug(" Actions pushed in priority %d (< %d),
restarting the scan (call %u)", minLevel, lvl, calls);
+ log_debug(" Actions pushed in priority %d (< "
+ "%d), restarting the scan (call"
+ " %u)", minLevel, lvl, calls);
#endif
return minLevel;
}
@@ -1593,7 +1593,8 @@
#ifdef GNASH_DEBUG
if ( actionsToProcess )
{
- log_debug(" Done processing actions in priority queue %d (call
%u)", lvl, calls);
+ log_debug(" Done processing actions in priority queue "
+ "%d (call %u)", lvl, calls);
}
#endif
@@ -1606,8 +1607,10 @@
{
if( ! processingActions() )
{
- // only flush the actions queue when we are processing the
queue.
- // ie. we don't want to flush the queue during executing user
event handlers,
+ // only flush the actions queue when we are
+ // processing the queue.
+ // ie. we don't want to flush the queue
+ // during executing user event handlers,
// which are not pushed at the moment.
return;
}
@@ -1670,7 +1673,8 @@
{
assert(lvl >= 0 && lvl < apSIZE);
#ifdef GNASH_DEBUG
- log_debug("Pushed action buffer for target %s",
target->getTargetPath());
+ log_debug("Pushed action buffer for target %s",
+ target->getTargetPath());
#endif
std::auto_ptr<ExecutableCode> code ( new GlobalCode(buf, target) );
@@ -2144,7 +2148,8 @@
}
else
{
- if ( strncasecmp(name.c_str(), "_level", 6) ) return false;
+ StringNoCaseEqual noCaseCmp;
+ if (!noCaseCmp(name.substr(0, 6), "_level")) return false;
}
if ( name.find_first_not_of("0123456789", 7) != std::string::npos ) return
false;
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h 2008-08-18 23:53:04 +0000
+++ b/libcore/movie_root.h 2008-08-26 13:30:20 +0000
@@ -907,11 +907,6 @@
mouse_button_state m_mouse_button_state;
- // Flags for event handlers
- bool m_on_event_xmlsocket_ondata_called;
- bool m_on_event_xmlsocket_onxml_called;
- bool m_on_event_load_progress_called;
-
typedef std::map<int, Timer*> TimerMap;
TimerMap _intervalTimers;
=== modified file 'libcore/sprite_instance.h'
--- a/libcore/sprite_instance.h 2008-08-19 20:37:40 +0000
+++ b/libcore/sprite_instance.h 2008-08-26 13:30:20 +0000
@@ -569,44 +569,7 @@
int newdepth, as_object* init_object=NULL);
/// Dispatch event handler(s), if any.
- virtual bool on_event(const event_id& id);
-
-
- /// Do the events that (appear to) happen as the movie
- /// loads. frame1 tags and actions are executed (even
- /// before advance() is called). Then the onLoad event
- /// is triggered.
-
-// virtual void on_event_load()
-// {
-// execute_frame_tags(0);
-// do_actions();
-// on_event(event_id::LOAD);
-// }
-
- /// Do the events that happen when there is XML data waiting
- /// on the XML socket connection.
- /// FIXME: unimplemented
- virtual void on_event_xmlsocket_onxml()
- {
- log_debug("FIXME: %s: unimplemented\n", __FUNCTION__);
- on_event(event_id::XML);
- }
-
- /// Do the events that (appear to) happen on a
- /// specified interval.
- virtual void on_event_interval_timer()
- {
- log_debug("FIXME: %s: unimplemented\n", __FUNCTION__);
- on_event(event_id::TIMER);
- }
-
- /// Do the events that happen as a MovieClip (swf 7 only) loads.
- virtual void on_event_load_progress()
- {
- log_debug("FIXME: %s: unimplemented\n", __FUNCTION__);
- on_event(event_id::LOAD_PROGRESS);
- }
+ virtual bool on_event(const event_id& id);
// inherited from character class, see dox in character.h
as_environment& get_environment() {
=== modified file 'libcore/swf/PlaceObject2Tag.cpp'
--- a/libcore/swf/PlaceObject2Tag.cpp 2008-08-21 10:06:20 +0000
+++ b/libcore/swf/PlaceObject2Tag.cpp 2008-08-26 13:30:20 +0000
@@ -227,7 +227,7 @@
ev->event().setKeyCode(ch);
}
- m_event_handlers.push_back(ev.release());
+ _eventHandlers.push_back(ev.release());
}
}
}
@@ -498,18 +498,22 @@
}
}
+
+/// Use to delete pointers efficiently with std::for_each,
+/// making sure that the type is complete.
+template<typename T>
+static void deleterHelper(T p)
+{
+ delete p;
+}
+
PlaceObject2Tag::~PlaceObject2Tag()
{
-
- for(size_t i=0; i<m_event_handlers.size(); ++i)
- {
- delete m_event_handlers[i];
- }
-
- for(size_t i=0; i<_actionBuffers.size(); ++i)
- {
- delete _actionBuffers[i];
- }
+ std::for_each(_eventHandlers.begin(), _eventHandlers.end(),
+ &deleterHelper<EventHandlers::value_type>);
+
+ std::for_each(_actionBuffers.begin(), _actionBuffers.end(),
+ &deleterHelper<ActionBuffers::value_type>);
}
/* public static */
=== modified file 'libcore/swf/PlaceObject2Tag.h'
--- a/libcore/swf/PlaceObject2Tag.h 2008-08-10 14:57:21 +0000
+++ b/libcore/swf/PlaceObject2Tag.h 2008-08-26 11:12:39 +0000
@@ -123,7 +123,7 @@
const std::string& getName() const { return m_name; }
const matrix& getMatrix() const { return m_matrix; }
const cxform& getCxform() const { return m_color_transform; }
- const EventHandlers& getEventHandlers() const { return m_event_handlers; }
+ const EventHandlers& getEventHandlers() const { return _eventHandlers; }
bool hasClipActions() const { return m_has_flags2 & HAS_CLIP_ACTIONS_MASK;
}
bool hasClipDepth() const { return m_has_flags2 & HAS_CLIP_DEPTH_MASK; };
@@ -152,7 +152,7 @@
boost::uint32_t all_event_flags;
/// NOTE: getPlaceType() is dependent on the enum values.
- enum place_type
+ enum PlaceType
{
REMOVE = 0,
MOVE = 1,
@@ -185,7 +185,7 @@
ActionBuffers _actionBuffers;
- EventHandlers m_event_handlers;
+ EventHandlers _eventHandlers;
// read SWF::PLACEOBJECT
void readPlaceObject(SWFStream& in);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r9644: Minor optimizations and removal of unused functions.,
Benjamin Wolsey <=