Browse Source

Make VMap::find_nearest return -1 when empty

Haoyu Qiu 3 years ago
parent
commit
3057b19daa
1 changed files with 3 additions and 0 deletions
  1. 3 0
      core/templates/vmap.h

+ 3 - 0
core/templates/vmap.h

@@ -142,6 +142,9 @@ public:
 	}
 	}
 
 
 	int find_nearest(const T &p_val) const {
 	int find_nearest(const T &p_val) const {
+		if (_cowdata.is_empty()) {
+			return -1;
+		}
 		bool exact;
 		bool exact;
 		return _find(p_val, exact);
 		return _find(p_val, exact);
 	}
 	}