game engines/web frameworks: 27 CWE-407 defects + 3 CLEAN; 194 sites, 78 ecosystems
This commit is contained in:
parent
547a9f5738
commit
4d3fcc8e73
76 changed files with 6216 additions and 17 deletions
|
|
@ -0,0 +1,32 @@
|
|||
--- a/panda/src/pgraph/camera.h
|
||||
+++ b/panda/src/pgraph/camera.h
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "pandaNode.h"
|
||||
#include "luse.h"
|
||||
#include "small_vector.h"
|
||||
+#include "pset.h"
|
||||
|
||||
...
|
||||
|
||||
- typedef small_vector<DisplayRegion *> DisplayRegions;
|
||||
+ // Unordered set: O(1) add/remove/contains.
|
||||
+ // Iteration order is irrelevant for this container (used only for ownership tracking).
|
||||
+ typedef pset<DisplayRegion *> DisplayRegions;
|
||||
DisplayRegions _display_regions;
|
||||
|
||||
--- a/panda/src/pgraph/camera.cxx
|
||||
+++ b/panda/src/pgraph/camera.cxx
|
||||
@@ -241,13 +241,11 @@ add_display_region(DisplayRegion *display_region) {
|
||||
- _display_regions.push_back(display_region);
|
||||
+ _display_regions.insert(display_region);
|
||||
}
|
||||
|
||||
void Camera::
|
||||
remove_display_region(DisplayRegion *display_region) {
|
||||
- DisplayRegions::iterator dri =
|
||||
- std::find(_display_regions.begin(), _display_regions.end(), display_region);
|
||||
- if (dri != _display_regions.end()) {
|
||||
- _display_regions.erase(dri);
|
||||
- }
|
||||
+ _display_regions.erase(display_region); // O(1) hash erase; no-op if absent
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
--- a/panda/src/display/graphicsOutput.h
|
||||
+++ b/panda/src/display/graphicsOutput.h
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "pvector.h"
|
||||
#include "pmap.h"
|
||||
+#include "pset.h"
|
||||
|
||||
...
|
||||
|
||||
- typedef pvector< PT(DisplayRegion) > TotalDisplayRegions;
|
||||
- TotalDisplayRegions _total_display_regions;
|
||||
+ // Map from raw pointer → owning PT ref for O(1) find+erase.
|
||||
+ // Insertion order is not required here; active-region sort happens in
|
||||
+ // do_determine_display_regions() which rebuilds _active_display_regions
|
||||
+ // from scratch on each stale cycle.
|
||||
+ typedef pmap<DisplayRegion *, PT(DisplayRegion)> TotalDisplayRegions;
|
||||
+ TotalDisplayRegions _total_display_regions;
|
||||
|
||||
--- a/panda/src/display/graphicsOutput.cxx
|
||||
+++ b/panda/src/display/graphicsOutput.cxx
|
||||
@@ -1601,8 +1601,8 @@ add_display_region(DisplayRegion *display_region) {
|
||||
- _total_display_regions.push_back(display_region);
|
||||
+ _total_display_regions[display_region] = PT(DisplayRegion)(display_region);
|
||||
}
|
||||
|
||||
@@ -1617,15 +1617,14 @@ do_remove_display_region(DisplayRegion *display_region) {
|
||||
nassertr(display_region != _overlay_display_region, false);
|
||||
|
||||
- PT(DisplayRegion) drp = display_region;
|
||||
- TotalDisplayRegions::iterator dri =
|
||||
- find(_total_display_regions.begin(), _total_display_regions.end(), drp);
|
||||
- if (dri != _total_display_regions.end()) {
|
||||
+ TotalDisplayRegions::iterator dri = _total_display_regions.find(display_region);
|
||||
+ if (dri != _total_display_regions.end()) {
|
||||
// Let's aggressively clean up the display region too.
|
||||
display_region->cleanup();
|
||||
display_region->_window = nullptr;
|
||||
_total_display_regions.erase(dri);
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1644,8 +1643,8 @@ do_determine_display_regions(GraphicsOutput::CData *cdata) {
|
||||
cdata->_active_display_regions.clear();
|
||||
cdata->_active_display_regions.reserve(_total_display_regions.size());
|
||||
|
||||
- TotalDisplayRegions::const_iterator dri;
|
||||
- for (dri = _total_display_regions.begin();
|
||||
- dri != _total_display_regions.end();
|
||||
- ++dri) {
|
||||
- DisplayRegion *display_region = (*dri);
|
||||
+ for (auto &[raw_ptr, pt_ref] : _total_display_regions) {
|
||||
+ DisplayRegion *display_region = raw_ptr;
|
||||
if (display_region->is_active()) {
|
||||
cdata->_active_display_regions.push_back(display_region);
|
||||
Loading…
Add table
Add a link
Reference in a new issue