Changes between Version 3 and Version 4 of Ticket #6433


Ignore:
Timestamp:
03/01/2018 10:03:50 AM (2 years ago)
Author:
mjethani
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #6433 – Description

    v3 v4  
    6767}}} 
    6868 
    69 The loop terminates if the first URL returned is truth-y, and in that case the function `getURLsFromElement` does not bother checking the values of the `srcset` attributes and the attribute values of the children. Without generators, the callee would need to know the requirements of the caller up front in order to do this kind of optimization, but with generators the caller decides when to terminate the callee. 
     69The loop terminates if the first URL returned is truthy, and in that case the function `getURLsFromElement` does not bother checking the values of the `srcset` attributes and the attribute values of the children. Without generators, the callee would need to know the requirements of the caller up front in order to do this kind of optimization, but with generators the caller decides when to terminate the callee. 
    7070 
    7171This is already an improvement, but we can go further in terms of code readability. For example, by adopting a functional style: 
     
    8787Note that this does negate some of the aforementioned performance benefits, since now we're trimming every URL before it's even needed. 
    8888 
    89 Further, if yielding false-y values is not a concern, this can be combined with object destructuring in the parameter list to make the code even more succinct: 
     89Further, if yielding falsy values is not a concern, this can be combined with object destructuring in the parameter list to make the code even more succinct: 
    9090 
    9191{{{