altmp / altv-client-js

Official clientside JavaScript runtime for alt:V
6 stars 7 forks source link

Add streamedIn getter #49

Closed LeonMrBonnie closed 3 years ago

LeonMrBonnie commented 3 years ago

The performance with this should be fine, as there will never be more than 128 entities in stream range at once anyway.

FabianTerhorst commented 3 years ago

I would prefer a std map here. So that the delete doesn't need O(n) by 128 players. Not sure how much difference it would make.

LeonMrBonnie commented 3 years ago

I would prefer a std map here. So that the delete doesn't need O(n) by 128 players. Not sure how much difference it would make.

Map with ID as key and the Entity as value?

FabianTerhorst commented 3 years ago

Yes thats what i meant

LeonMrBonnie commented 3 years ago

@FabianTerhorst Should be fine now

FabianTerhorst commented 3 years ago

Wouldnt it be possible to use v8::map so that conversion in the getter isnt needed.

LeonMrBonnie commented 3 years ago

Wouldnt it be possible to use v8::map so that conversion in the getter isnt needed.

A v8 map is much slower than a C++ map. Also, the GetOrCreateEntity does nothing else than accessing another C++ map to get the underlying stored entity, so it's very fast.