W3C home > Mailing lists > Public > public-device-apis-log@w3.org > December 2016

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

From: Tobie Langel via GitHub <sysbot+gh@w3.org>
Date: Sun, 18 Dec 2016 11:09:17 +0000
To: public-device-apis-log@w3.org
Message-ID: <issue_comment.created-267815304-1482059356-sysbot+gh@w3.org>
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

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 12:18:52 UTC