Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/overpass_api/statements/area_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,20 @@ void Area_Query_Statement::get_ranges

bool Area_Constraint::delivers_data(Resource_Manager& rman)
{
int counter = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int counter = 0 in line 311 should probably be removed as well, otherwise line 321 won't return the correct value I guess (variable counter gets shadowed).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right! forgot to remove that one


if (!area->areas_from_input())
return false;
{
Block_Backend< Uint31_Index, Area_Skeleton > area_locations_db
(rman.get_area_transaction()->data_index(area_settings().AREAS));
for (Block_Backend< Uint31_Index, Area_Skeleton >::Flat_Iterator
it(area_locations_db.flat_begin());
!(it == area_locations_db.flat_end()); ++it)
{
if (area->get_submitted_id() == it.object().id.val())
Copy link
Contributor

@mmd-osm mmd-osm Mar 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if you could use it.handle() ... instead to get the id (avoids some unneeded object instatiation) - not super urgent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean just changing it to it.handle().object().id.val(), right? For me that seems to works as well.

It probably should also be changed on line 244

Copy link
Contributor

@mmd-osm mmd-osm Mar 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it.handle().id() in mind - we have something similar elsewhere but I don't know if this also works in this context without further checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yes, that makes more sense 🙈 -> 4d9992d

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think even the .val() at the end is not needed as id() already returns the right type. Can you maybe test this again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I get the following compile-time error (gcc 6.2):

error: no match for ‘operator==’ (operand types are ‘long long int’ and ‘Area_Skeleton::Id_Type {aka Uint32_Index}’

Uint32_Index has the == operator implemented only for comparing with other Uint32_Index values while Area_Query_Statement (for some reason) stores the id it gets in a 64bit integer.

But I think that calling .val() here shouldn't be an issue, since the compiler can inline/optimize that away very easily.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fine, let's keep val(). I didn't have the source available when commenting and didn't exactly remember when it was necessary.

counter += it.object().used_indices.size();
}
}
else
{
map< string, Set >::const_iterator mit = rman.sets().find(area->get_input());
Expand All @@ -305,8 +317,8 @@ bool Area_Constraint::delivers_data(Resource_Manager& rman)
counter += it2->used_indices.size();
}

return (counter <= 12);
}
return (counter <= 12);
}


Expand Down
1 change: 1 addition & 0 deletions src/overpass_api/statements/area_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Area_Query_Statement : public Output_Statement
const Statement& query, Resource_Manager& rman);

bool areas_from_input() const { return (submitted_id == 0); }
long long get_submitted_id() const { return submitted_id; }
string get_input() const { return input; }

static bool is_used() { return is_used_; }
Expand Down