2010/1/15 Jon Cruz <jon@...18...>:
- Do we need to be using it? That is, are there any alternatives to the code creating warnings?
Things such as vector instead of list, map instead of hash_map, etc.
Using a list will result in completely unacceptable performance. Most actions will be O(n^2) where n is the number of selected nodes, because most actions that work on selected nodes check whether each one is selected. Using a sorted set instead of a hash set / hash map is slightly better - O(n log n), but this structure is also inadequate. The correct alternative is fixing Apple's broken and outdated headers and using a hash set, then we get O(n) on average.
- Can we encapsulate it? That is, do we need to leave things in .h files that other things include, or can they be moved inside specific files?
The hash set is a member of ControlPointSelection, so it has to be in the header.
- Is it cross-platform? Remember, we need to keep Inkscape compatible with multiple platforms, including MS Windows, Linux, OS X, BSD, Solaris, etc.
The current workaround is as cross platform as GCC. The correct solution (tr1/unordered_map) is more cross platform, because it is not a GCC extension, but doesn't work with Apple's GCC 4.0.0. It works with non-Apple GCC 4.0.2 and later and was fixed over 4 years ago. See http://mohri-lt.cs.nyu.edu/twiki/bin/view/FST/CompilingOnMacOSX (thanks to ~suv for finding this).
Once ~suv confirms that using a non-broken version of the compiler works, I'll go back to the non-deprecated headers and add configure code that detects the broken unordered_set. Is this acceptable?
So in this case of moving things from verbs.cpp to selection-chemistry.cpp I don't think the warning count decreases However, the encapsulation is much better as the cohesion goes up while the coupling goes down. The function of verbs.cpp returns to that of just dispatching commands, while all the selection magic goes over into selection-chemistry.cpp.
The problem is not that verbs.cpp uses control-point-selection.h. The problem is that selection-chemistry.cpp is an old pile of magic stuff that should be put in better places, and that verbs.cpp is a God-file. Another offender in this category is widgets/toolbox.cpp.
Regards, Krzysztof