jviereck/pdfListView — pull request #17 by jviereck (2014-09-07 20:59:15+00:00)
Title: Small code cleanups

@jpallen, I think this code cleanup touches code you have written. Can you please have a look?

What I did:
1) remove the state variable `this.pdfPosition` and the associated functions `savePdfPosition()` and `restorePdfPosition()`. Handling state is evil and in this case I think the code complexity stays the same when storing the current pdfPosition in the `layout()` function in a local variable instead of a state variable on the `ListView` object
2) `if (typeof pdfPosition !== "undefined" && pdfPosition != null) {...}` can be simplified to `if (pdfPosition) {...}` I guess? Less code to read and I also think the later should be faster.
3) replaced the `delete` operator with `null` assignments. Using the `delete` operator gives JS VMs a hard time. Quoting the Google JavaScript Code Guide from [1]:

> "In modern JavaScript engines, changing the number of properties on an object is much slower than reassigning the values. The delete keyword should be avoided except when it is necessary to remove a property from an object's iterated list of keys, or to change the result of if (key in obj)."

[1]: https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=delete#delete