[Qgis-developer] comments on qgsvectorlayer.cpp

Albert Cervera i Areny albert at nan-tic.com
Thu Aug 30 19:22:48 EDT 2007

Recently I've been taking a look a the vector layer source code and trying to 
find with the help of valgrind and kcachegrind where most of the time was 
spent. With the files I took I started playing a bit and it seemed that most 
time was spent in the drawPolygon function. Not a big surprise given the 
sample data, but a good place to start.
	I looked at it and tried to redo some things to find if I could do something 
to improve performance. The result, no performance gain, at least no user 
perceivable difference, but the code seemed much clearer because path is 
filled in the first loop. However, to achieve that I removed the code 
responsible for clipping values that don't fit into 16-bit signed values as 
it seems that was a Qt 3 limitation and Qt4 possibly has an internal 
solution/workaround for that. (At least I see no warnings in Qt4 docs). If 
that code is correct, then something similar could be done for drawLineString 
and drawFeature.
	Please, see attached a diff for current trunk. Of course that's working fine 
in my tests.

	By the way, as I said what I wanted to find is a way to improve performance. 
For example with the map of spain I've been playing it takes 4 seconds to 
repaint the hole map with 3 layers (1 with polygons and a couple with lines). 
Looking at the code a possible solution that comes to mind would be to try to 
keep the generated polygon (or line or whatever) path from one call to 
another, maybe adding polygons in the path on demand when the user moves. I 
imagine that would mean redesigning the the way zooming and scrolling is 
handled. But probably I'm also ignoring many other aspects, as I've only 
worked with a very little part of the source code.
	Any way, I was interested in knowing how it all worked and try to find out if 
there've been some discussions regarding theses performance issues.

Albert Cervera i Areny
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qgsvectorlayer.cpp.diff
Type: text/x-diff
Size: 7742 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/qgis-developer/attachments/20070831/21e9fe4f/qgsvectorlayer.cpp.bin

More information about the Qgis-developer mailing list