Skip to content

Commit

Permalink
Merge branch 'task/adjust-megaintegermap' into 'develop'
Browse files Browse the repository at this point in the history
CHT-822. Adjust MegaIntegerMap getters (v2)

See merge request megachat/MEGAchat!1521
  • Loading branch information
jgandres committed Feb 16, 2023
2 parents e34e437 + 5724bc4 commit 0fdcf61
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
14 changes: 8 additions & 6 deletions bindings/Objective-C/MEGAChatScheduledRules.mm
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ - (uint64_t)until {

for (int i = 0; i < integerMap->size(); i++)
{
long long key;
long long value;
integerMap->at(i, key, value);

NSMutableArray<NSNumber *> *keyValueArray = @[[NSNumber.alloc initWithInt:key], [NSNumber.alloc initWithInt:value]];
[integerArray addObject:keyValueArray];
MegaIntegerList *keyList = integerMap->getKeys();
for (int i = 0; i < keyList->size(); i++)
{
uint64_t key = keyList->get(i);
MegaIntegerList *valueList = integerMap->get(key);
NSMutableArray<NSNumber *> *keyValueArray = @[[NSNumber.alloc initWithInt:key], [NSNumber.alloc initWithInt:valueList->get(0)]];
[integerArray addObject:keyValueArray];
}
}

delete integerMap;
Expand Down
22 changes: 13 additions & 9 deletions src/chatClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5538,12 +5538,14 @@ KarereScheduledRules::KarereScheduledRules(const mega::MegaScheduledRules *rules
if (rules->byMonthWeekDay() && rules->byMonthWeekDay()->size())
{
mByMonthWeekDay.reset(new karere_rules_map());
for (size_t i = 0; i < rules->byMonthWeekDay()->size(); i++)
std::unique_ptr<::mega::MegaIntegerList> keys(rules->byMonthWeekDay()->getKeys());
for (auto i = 0 ; i < keys->size(); i++)
{
long long key;
long long value;
if (rules->byMonthWeekDay()->at(i, key, value))
int64_t key = keys->get(i);
std::unique_ptr<::mega::MegaIntegerList> values(rules->byMonthWeekDay()->get(key));
for (auto j = 0 ; j < values->size(); j++)
{
int64_t value = values->get(j);
mByMonthWeekDay->emplace(key, value);
}
}
Expand Down Expand Up @@ -5616,13 +5618,15 @@ bool KarereScheduledRules::equalTo(const ::mega::MegaScheduledRules* r) const
}

karere_rules_map auxMap;
for (unsigned long long i = 0; i < r->byMonthWeekDay()->size(); i++)
std::unique_ptr<::mega::MegaIntegerList> keys(r->byMonthWeekDay()->getKeys());
for (auto i = 0 ; i < keys->size(); i++)
{
long long auxkey;
long long auxvalue;
if (r->byMonthWeekDay()->at(i, auxkey, auxvalue))
int64_t key = keys->get(i);
std::unique_ptr<::mega::MegaIntegerList> values(r->byMonthWeekDay()->get(key));
for (auto j = 0 ; j < values->size(); j++)
{
auxMap.emplace(auxkey, auxvalue);
int64_t value = values->get(j);
auxMap.emplace(key, value);
}
}

Expand Down

0 comments on commit 0fdcf61

Please sign in to comment.