~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/JavaScriptCore/runtime/StructureChain.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
namespace JSC {
34
34
 
35
 
StructureChain::StructureChain(Structure* structure)
 
35
StructureChain::StructureChain(Structure* head)
36
36
{
37
 
    size_t size = 1;
38
 
 
39
 
    Structure* tmp = structure;
40
 
    while (!tmp->storedPrototype()->isNull()) {
 
37
    size_t size = 0;
 
38
    for (Structure* current = head; current; current = current->storedPrototype().isNull() ? 0 : asObject(current->storedPrototype())->structure())
41
39
        ++size;
42
 
        tmp = asCell(tmp->storedPrototype())->structure();
43
 
    }
44
40
    
45
41
    m_vector.set(new RefPtr<Structure>[size + 1]);
46
42
 
47
 
    size_t i;
48
 
    for (i = 0; i < size - 1; ++i) {
49
 
        m_vector[i] = structure;
50
 
        structure = asObject(structure->storedPrototype())->structure();
51
 
    }
52
 
    m_vector[i] = structure;
53
 
    m_vector[i + 1] = 0;
 
43
    size_t i = 0;
 
44
    for (Structure* current = head; current; current = current->storedPrototype().isNull() ? 0 : asObject(current->storedPrototype())->structure())
 
45
        m_vector[i++] = current;
 
46
    m_vector[i] = 0;
54
47
}
55
48
 
56
 
bool structureChainsAreEqual(StructureChain* chainA, StructureChain* chainB)
 
49
bool StructureChain::isCacheable() const
57
50
{
58
 
    if (!chainA || !chainB)
59
 
        return false;
60
 
 
61
 
    RefPtr<Structure>* a = chainA->head();
62
 
    RefPtr<Structure>* b = chainB->head();
63
 
    while (1) {
64
 
        if (*a != *b)
65
 
            return false;
66
 
        if (!*a)
67
 
            return true;
68
 
        a++;
69
 
        b++;
 
51
    uint32_t i = 0;
 
52
    
 
53
    while (m_vector[i]) {
 
54
        // Both classes of dictionary structure may change arbitrarily so we can't cache them
 
55
        if (m_vector[i]->isDictionary())
 
56
            return false;
 
57
        if (!m_vector[i++]->typeInfo().hasDefaultGetPropertyNames())
 
58
            return false;
70
59
    }
 
60
    return true;
71
61
}
72
62
 
73
63
} // namespace JSC