[Webkit-unassigned] [Bug 80490] [Microdata] Implement cache mechanism for HTMLPropertiesCollection.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Mar 27 06:31:34 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=80490





--- Comment #11 from Arko Saha <nghq36 at motorola.com>  2012-03-27 06:31:34 PST ---
(In reply to comment #10)
> It seems like this entire block is redundant and can be merged into the for loop below.
> 

The algorithm of HTMLPropertiesCollection::item() method is as below:

In if (!m_cache.current || m_cache.position > index) {.. }

Here we reset the position to 0. set current to the 0th property in the collection. set the itemRefElementPosition to the position in itemRefElements where we find the 0th property.

The first block is responsible for finding the 0th property in the itemRefElements list. Then searching required property in the collection starts in the second block. 
So we require this block to get started with the searching in the second block.

In the second block i.e, for (unsigned i = m_cache.itemRefElementPosition..) :

1. The outer for loop picks an element from itemRefElements.
2. The inner for loop is responsible to find a property in that element i.e, itemRefElements[i]. using itemAfter() method.
itemAfter() returns the 0th property if the previous element is null else returns the next property in the itemRefElements[i]. It will return null if it already processed all properties in itemRefElements[i].
3. increment the currentPosition appropriately. 
4. If the currentPosition is equal to index then return the property. else find the next property.
5. If the next property is null that means itemRefElements[i] has no more property to process. then control will come to the outer for loop and picks the next element in the itemRefElements. And executes above steps (repeat from step 1). 

So I think if we merge two blocks here then the algorithm would become little unclear and complex.

In the following block,
if (!m_cache.current || m_cache.position > index) {m_cache.position = 0; ... }
we are resetting the position to 0, but if we do not set the m_cache.current to the first property in the collection, it might require some special handling for the 0th property to start the search with.. which might complicate the algo.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list