Repository: godotengine/godot
File: scene/main/resource_preloader.cpp (C++)

Code before:
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
/**************************************************************************/

#include "resource_preloader.h"
#include "core/templates/rb_set.h"
void ResourcePreloader::_set_resources(const Array &p_data) {
	resources.clear();

	ERR_FAIL_COND(p_data.size() != 2);
	Vector<String> names = p_data[0];
	Array resdata = p_data[1];

	ERR_FAIL_COND(names.size() != resdata.size());

	for (int i = 0; i < resdata.size(); i++) {
		String name = names[i];
		Ref<Resource> resource = resdata[i];
		ERR_CONTINUE(!resource.is_valid());
		resources[name] = resource;

		//add_resource(name,resource);
	}
}

Array ResourcePreloader::_get_resources() const {
	Vector<String> names;
	Array arr;
	arr.resize(resources.size());
	names.resize(resources.size());

	RBSet<String> sorted_names;

	for (const KeyValue<StringName, Ref<Resource>> &E : resources) {
		sorted_names.insert(E.key);
	}

	int i = 0;
	for (const String &E : sorted_names) {
		names.set(i, E);
		arr[i] = resources[E];
		i++;
	}

	Array res;
	res.push_back(names);

Review comment (suggestion):
```suggestion
		//add_resource(names[i],resource);
```
To prevent confusion if this comment is restored

Code after:
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
/**************************************************************************/

#include "resource_preloader.h"
#include "core/templates/rb_set.h"
void ResourcePreloader::_set_resources(const Array &p_data) {
	resources.clear();

	ERR_FAIL_COND(p_data.size() != 2);
	Vector<String> names = p_data[0];
	Array resdata = p_data[1];

	ERR_FAIL_COND(names.size() != resdata.size());

	for (int i = 0; i < resdata.size(); i++) {
		Ref<Resource> resource = resdata[i];
		ERR_CONTINUE(!resource.is_valid());
		resources[names[i]] = resource;

		//add_resource(names[i],resource);
	}
}

Array ResourcePreloader::_get_resources() const {
	Vector<String> names;
	Array arr;
	arr.resize(resources.size());
	names.resize(resources.size());

	RBSet<String> sorted_names;

	for (const KeyValue<StringName, Ref<Resource>> &E : resources) {
		sorted_names.insert(E.key);
	}

	int i = 0;
	for (const String &E : sorted_names) {
		names.set(i, E);
		arr[i] = resources[E];
		i++;
	}

	Array res;
	res.push_back(names);
	res.push_back(arr);