[cairo-commit] cairomm/cairomm context.cc, 1.17, 1.18 pattern.cc, 1.9, 1.10

Jonathon Jongsma commit at pdx.freedesktop.org
Thu Mar 22 08:19:54 PDT 2007


Committed by: jjongsma

Update of /cvs/cairo/cairomm/cairomm
In directory kemper:/tmp/cvs-serv13533/cairomm

Modified Files:
	context.cc pattern.cc 
Log Message:
2007-03-22  Jonathon Jongsma  <jjongsma at gnome.org>

	* cairomm/context.cc: Minor comment cleanups
	* cairomm/pattern.cc: get the gradient stops by reference parameter instead
	of returning by value.  This saves an extra copy of the vector.


Index: context.cc
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/context.cc,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- context.cc	21 Mar 2007 20:56:39 -0000	1.17
+++ context.cc	22 Mar 2007 15:19:46 -0000	1.18
@@ -414,8 +414,8 @@
 void Context::copy_clip_rectangle_list(std::vector<Rectangle>& rectangles)
 {
   cairo_rectangle_list_t* c_list = 0;
-  // FIXME: It would be nice if the cairo interface didn't copy it into a
-  // C array first and just let us do the copying...
+  // It would be nice if the cairo interface didn't copy it into a C array first
+  // and just let us do the copying...
   c_list = cairo_copy_clip_rectangle_list(m_cobject);
   // the rectangle list contains a status field that we need to check and the
   // cairo context also has a status that we need to check
@@ -606,7 +606,7 @@
 {
   // FIXME: do we need to allocate this array dynamically?  I seem to remember
   // some compilers have trouble with allocating arrays on the stack when the
-  // array size isn't a compiler constant...
+  // array size isn't a compile-time constant...
   const int cnt = cairo_get_dash_count(m_cobject);
   double dash_array[cnt];
   cairo_get_dash(m_cobject, dash_array, &offset);

Index: pattern.cc
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/pattern.cc,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- pattern.cc	21 Mar 2007 20:56:39 -0000	1.9
+++ pattern.cc	22 Mar 2007 15:19:46 -0000	1.10
@@ -188,17 +188,18 @@
   check_object_status_and_throw_exception(*this);
 }
 
-std::vector<ColorStop>
-Gradient::get_color_stops ()
+void
+Gradient::get_color_stops (std::vector<ColorStop>& stops)
 {
-  // we could save a copy here by returning it as an output reference parameter
-  // instead of returning the array by value.
-  std::vector<ColorStop> stops;
+  // clear any existing values from the passed array since we'll be adding them
+  // on to the end of the array one-by-one
+  stops.clear ();
+
   int num_stops;
   // we can ignore the return value since we know this is a gradient pattern
   cairo_pattern_get_color_stop_count(m_cobject, &num_stops);
   // since we know the total number of stops, we can avoid re-allocation with
-  // each addition to the vector
+  // each addition to the vector by pre-allocating the required number
   stops.reserve(num_stops);
   for (int i = 0; i < num_stops; ++i)
   {



More information about the cairo-commit mailing list