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: moka via GitHub <sysbot+gh@w3.org>
Date: Fri, 16 Dec 2016 18:41:36 +0000
To: public-device-apis-log@w3.org
Message-ID: <issue_comment.created-267665668-1481913693-sysbot+gh@w3.org>
> 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.
Haven't seen such pattern anywhere in a W3C.

Additionally, it is not necessary all readings data is required by 
developer, he might want to store only some of it. So clearly there 
will be overhead when all of it is not needed.

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.
Plus this avoids any allocations.

-- 
GitHub Notification of comment by Maksims
Please view or discuss this issue at 
https://github.com/w3c/sensors/issues/153#issuecomment-267665668 using
 your GitHub account
Received on Friday, 16 December 2016 18:41:58 UTC

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