File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 3
3
4
4
namespace NColorManagement {
5
5
static uint32_t lastImageID = 0 ;
6
- static std::map<SImageDescription, uint32_t > knownDescriptionIds; // expected to be small1
6
+ static std::map<uint32_t , SImageDescription > knownDescriptionIds; // expected to be small
7
7
8
8
const SPCPRimaries& getPrimaries (ePrimaries name) {
9
9
switch (name) {
@@ -21,22 +21,25 @@ namespace NColorManagement {
21
21
}
22
22
}
23
23
24
+ // TODO make image descriptions immutable and always set an id
25
+
24
26
uint32_t SImageDescription::findId () const {
25
- const auto known = knownDescriptionIds.find (*this );
26
- if (known != knownDescriptionIds.end ())
27
- return known->second ;
28
- else {
29
- const auto newId = ++lastImageID;
30
- knownDescriptionIds.insert (std::make_pair (*this , newId));
31
- return newId;
27
+ for (auto it = knownDescriptionIds.begin (); it != knownDescriptionIds.end (); ++it) {
28
+ if (it->second == *this )
29
+ return it->first ;
32
30
}
31
+
32
+ const auto newId = ++lastImageID;
33
+ knownDescriptionIds.insert (std::make_pair (newId, *this ));
34
+ return newId;
33
35
}
34
36
35
37
uint32_t SImageDescription::getId () const {
36
38
return id > 0 ? id : findId ();
37
39
}
38
40
39
41
uint32_t SImageDescription::updateId () {
42
+ id = 0 ;
40
43
id = findId ();
41
44
return id;
42
45
}
You can’t perform that action at this time.
0 commit comments