Ignore:
Timestamp:
Mar 16, 2010, 1:46:02 PM (15 years ago)
Author:
Darin Adler
Message:

Added arrayLength function and used it instead of hand-written code.

Reviewed by Sam Weinig.

Removed PtrAndFlags.h. The file was removed long ago.

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::privateExecute): Use arrayLength.

  • runtime/Collector.h:

(JSC::CollectorBitmap::count): Remove WTF:: prefix from use
of bitCount. In WTF we inject things into the global namespace
and this is no exception.

  • runtime/DatePrototype.cpp:

(JSC::formatLocaleDate): Use arrayLength.

  • runtime/JSFunction.h:

(JSC::JSFunction::nativeFunction): Remove WTF:: prefix as above.
(JSC::JSFunction::scopeChain): Ditto.
(JSC::JSFunction::setScopeChain): Ditto.
(JSC::JSFunction::setNativeFunction): Ditto.

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::reset): Use arrayLength.

  • runtime/JSImmediate.h:

(JSC::reinterpretDoubleToIntptr): Remove WTF:: prefix as above.
(JSC::reinterpretIntptrToDouble): Ditto.

  • runtime/JSONObject.cpp:

(JSC::Stringifier::appendQuotedString): Use arrayLength.
(JSC::Stringifier::toJSON): Ditto.
(JSC::Stringifier::appendStringifiedValue): Ditto.

  • runtime/SmallStrings.cpp:

(JSC::SmallStrings::SmallStrings): Ditto.

  • runtime/UString.cpp:

(JSC::UString::from): Use arrayLength.

  • wtf/StdLibExtras.h:

(WTF::bitwise_cast): Marked this inline!
(WTF::arrayLength): Added function template (actually written by Sam).
Added using declarations for public things in WTF namespace defined
in this file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/StdLibExtras.h

    r55633 r56081  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727#define WTF_StdLibExtras_h
    2828
     29#include <stdlib.h>
    2930#include <wtf/Assertions.h>
    3031
     
    5455namespace WTF {
    5556
    56     /*
    57      * C++'s idea of a reinterpret_cast lacks sufficient cojones.
    58      */
     57    // C++'s idea of a reinterpret_cast lacks sufficient cojones.
    5958    template<typename TO, typename FROM>
    60     TO bitwise_cast(FROM from)
     59    inline TO bitwise_cast(FROM from)
    6160    {
    6261        COMPILE_ASSERT(sizeof(TO) == sizeof(FROM), WTF_bitwise_cast_sizeof_casted_types_is_equal);
     
    7776    }
    7877
     78    // Returns the length of an array. Use instead of macros such as ARRAYSIZE.
     79    template<class ElementType, size_t length>
     80    inline size_t arrayLength(ElementType (&)[length])
     81    {
     82        return length;
     83    }
     84
    7985} // namespace WTF
    8086
     87using WTF::arrayLength;
     88using WTF::bitCount;
     89using WTF::bitwise_cast;
     90
    8191#endif
Note: See TracChangeset for help on using the changeset viewer.