Browse Source

Omit duplicate tags in Model.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
80d08ec15c
3 changed files with 9 additions and 1 deletions
  1. +0
    -1
      include/plugin/Model.hpp
  2. +1
    -0
      src/engine/Engine.cpp
  3. +8
    -0
      src/plugin/Model.cpp

+ 0
- 1
include/plugin/Model.hpp View File

@@ -1,5 +1,4 @@
#pragma once
#include <set>

#include <jansson.h>



+ 1
- 0
src/engine/Engine.cpp View File

@@ -1,4 +1,5 @@
#include <algorithm>
#include <set>
#include <thread>
#include <condition_variable>
#include <mutex>


+ 8
- 0
src/plugin/Model.cpp View File

@@ -1,3 +1,5 @@
#include <algorithm>

#include <plugin/Model.hpp>
#include <plugin.hpp>
#include <asset.hpp>
@@ -32,6 +34,12 @@ void Model::fromJson(json_t* rootJ) {
json_array_foreach(tagsJ, i, tagJ) {
std::string tag = json_string_value(tagJ);
int tagId = tag::findId(tag);

// Omit duplicates
auto it = std::find(tags.begin(), tags.end(), tagId);
if (it != tags.end())
continue;

if (tagId >= 0)
tags.push_back(tagId);
}


Loading…
Cancel
Save