Re: [sensors] Don't allocate response objects to avoid triggering GC

Replying to @Maksims:

>> Could we instead provide a method that will fill sensor reading 
data, e.g. Sensor.getReading(Dictionary out); or 
Sensor.read(Dictionary out);? This will allow to reuse object, yet, 
main interface is not polluted with unwanted fields and extensibility 
is not lost.
>
>This will require extra function call by a developer every time he 
wants to get some data out of a sensor? And it requires preparation - 
need to create object to store readings.

I don't think a function call is a huge perf drag nowadays. It was in 
the days of IE6, but those are behind us at this point.

>Direct access by either `sensor.x` or `sensor.data.x` - provides 
ability to store data developer wants, and access to the data without 
a need to call a function and no need for any advance preparations.

These are getters, so in terms of cost, we're not far away from 
function calls afaik.

>Plus this avoids any allocations.

Yes. *That*'s the issue we want to avoid. The function call one is a 
red herring.

-- 
GitHub Notification of comment by tobie
Please view or discuss this issue at 
https://github.com/w3c/sensors/issues/153#issuecomment-267815304 using
 your GitHub account

Received on Sunday, 18 December 2016 11:09:23 UTC