Skip to content

Commit

Permalink
Bug 935789, part 1: Kill most uses of prbit.h, r=ehsan
Browse files Browse the repository at this point in the history
  • Loading branch information
jcranmer committed Nov 13, 2013
1 parent 9ff8e0e commit 381cef1
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 27 deletions.
4 changes: 2 additions & 2 deletions content/base/src/nsAttrAndChildArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

#include "nsAttrAndChildArray.h"

#include "mozilla/MathAlgorithms.h"
#include "mozilla/MemoryReporting.h"

#include "nsMappedAttributeElement.h"
#include "prbit.h"
#include "nsString.h"
#include "nsHTMLStyleSheet.h"
#include "nsRuleWalker.h"
Expand Down Expand Up @@ -772,7 +772,7 @@ nsAttrAndChildArray::GrowBy(uint32_t aGrowSize)
} while (size < minSize);
}
else {
size = 1u << PR_CeilingLog2(minSize);
size = 1u << mozilla::CeilingLog2(minSize);
}

bool needToInitialize = !mImpl;
Expand Down
5 changes: 2 additions & 3 deletions gfx/gl/GLContextProviderGLX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>

#include "mozilla/MathAlgorithms.h"
#include "mozilla/X11Util.h"

#include "prenv.h"
#include "prbit.h" // for PR_FLOOR_LOG2
#include "GLContextProvider.h"
#include "GLLibraryLoader.h"
#include "nsDebug.h"
Expand Down Expand Up @@ -299,8 +299,7 @@ GLXLibrary::CreatePixmap(gfxASurface* aSurface)
return None;
}
const XRenderDirectFormat& direct = format->direct;
int alphaSize;
PR_FLOOR_LOG2(alphaSize, direct.alphaMask + 1);
int alphaSize = FloorLog2(direct.alphaMask + 1);
NS_ASSERTION((1 << alphaSize) - 1 == direct.alphaMask,
"Unexpected render format with non-adjacent alpha bits");

Expand Down
1 change: 0 additions & 1 deletion modules/libpref/src/nsPrefBranch.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "nsWeakReference.h"
#include "nsClassHashtable.h"
#include "nsCRT.h"
#include "prbit.h"
#include "nsTraceRefcnt.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/MemoryReporting.h"
Expand Down
1 change: 0 additions & 1 deletion netwerk/cache/nsDiskCacheDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#endif

#include "prthread.h"
#include "prbit.h"

#include "private/pprio.h"

Expand Down
3 changes: 2 additions & 1 deletion netwerk/cache/nsMemoryCacheDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "nsIMemoryReporter.h"
#include "nsCRT.h"
#include "nsReadableUtils.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Telemetry.h"
#include <algorithm>

Expand Down Expand Up @@ -429,7 +430,7 @@ nsMemoryCacheDevice::EvictionList(nsCacheEntry * entry, int32_t deltaSize)
int32_t size = deltaSize + (int32_t)entry->DataSize();
int32_t fetchCount = std::max(1, entry->FetchCount());

return std::min(PR_FloorLog2(size / fetchCount), kQueueCount - 1);
return std::min((int)mozilla::FloorLog2(size / fetchCount), kQueueCount - 1);
}


Expand Down
1 change: 0 additions & 1 deletion netwerk/protocol/rtsp/controller/RtspController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "plbase64.h"
#include "prmem.h"
#include "prnetdb.h"
#include "prbit.h"
#include "zlib.h"
#include <algorithm>
#include "nsDebug.h"
Expand Down
1 change: 0 additions & 1 deletion rdf/base/src/nsRDFService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
#include "rdf.h"
#include "nsCRT.h"
#include "nsCRTGlue.h"
#include "prbit.h"
#include "mozilla/HashFunctions.h"

using namespace mozilla;
Expand Down
4 changes: 2 additions & 2 deletions xpcom/ds/nsSupportsArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include <string.h>
#include "prbit.h"
#include "mozilla/MathAlgorithms.h"
#include "nsSupportsArray.h"
#include "nsSupportsArrayEnumerator.h"
#include "nsIObjectInputStream.h"
Expand Down Expand Up @@ -129,7 +129,7 @@ void nsSupportsArray::GrowArrayBy(int32_t aGrowBy)
// Select the next power-of-two size in bytes above that if newSize is
// not a power of two.
if (newSize & (newSize - 1))
newSize = 1u << PR_CeilingLog2(newSize);
newSize = 1u << mozilla::CeilingLog2(newSize);

newCount = newSize / sizeof(mArray[0]);
}
Expand Down
4 changes: 2 additions & 2 deletions xpcom/glue/nsVoidArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "mozilla/MathAlgorithms.h"
#include "mozilla/MemoryReporting.h"
#include <stdlib.h>

#include "nsVoidArray.h"
#include "nsQuickSort.h"
#include "prbit.h"
#include "nsISupportsImpl.h" // for nsTraceRefcnt
#include "nsAlgorithm.h"

Expand Down Expand Up @@ -239,7 +239,7 @@ bool nsVoidArray::GrowArrayBy(int32_t aGrowBy)
}
else
{
PR_CEILING_LOG2(newSize, newSize);
newSize = mozilla::CeilingLog2(newSize);
newCapacity = CAPACITYOF_IMPL(1u << newSize);
}
}
Expand Down
20 changes: 9 additions & 11 deletions xpcom/glue/pldhash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "prbit.h"
#include "pldhash.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/MathAlgorithms.h"
#include "nsDebug.h" /* for PR_ASSERT */
#include "nsAlgorithm.h"
#include "mozilla/Likely.h"
Expand Down Expand Up @@ -45,22 +45,22 @@
table_->recursionLevel == IMMUTABLE_RECURSION_LEVEL)

#define INCREMENT_RECURSION_LEVEL(table_) \
PR_BEGIN_MACRO \
do { \
if (table_->recursionLevel != IMMUTABLE_RECURSION_LEVEL) \
++table_->recursionLevel; \
PR_END_MACRO
} while(0)
#define DECREMENT_RECURSION_LEVEL(table_) \
PR_BEGIN_MACRO \
do { \
if (table->recursionLevel != IMMUTABLE_RECURSION_LEVEL) { \
MOZ_ASSERT(table->recursionLevel > 0); \
--table->recursionLevel; \
} \
PR_END_MACRO
} while(0)

#else

#define INCREMENT_RECURSION_LEVEL(table_) PR_BEGIN_MACRO PR_END_MACRO
#define DECREMENT_RECURSION_LEVEL(table_) PR_BEGIN_MACRO PR_END_MACRO
#define INCREMENT_RECURSION_LEVEL(table_) do { } while(0)
#define DECREMENT_RECURSION_LEVEL(table_) do { } while(0)

#endif /* defined(DEBUG) */

Expand Down Expand Up @@ -206,8 +206,7 @@ PL_DHashTableInit(PLDHashTable *table, const PLDHashTableOps *ops, void *data,
if (capacity < PL_DHASH_MIN_SIZE)
capacity = PL_DHASH_MIN_SIZE;

int log2;
PR_CEILING_LOG2(log2, capacity);
int log2 = CeilingLog2(capacity);

capacity = 1u << log2;
if (capacity > PL_DHASH_MAX_SIZE)
Expand Down Expand Up @@ -661,8 +660,7 @@ PL_DHashTableEnumerate(PLDHashTable *table, PLDHashEnumerator etor, void *arg)
if (capacity < PL_DHASH_MIN_SIZE)
capacity = PL_DHASH_MIN_SIZE;

uint32_t ceiling;
PR_CEILING_LOG2(ceiling, capacity);
uint32_t ceiling = CeilingLog2(capacity);
ceiling -= PL_DHASH_BITS - table->hashShift;

(void) ChangeTable(table, ceiling);
Expand Down
4 changes: 2 additions & 2 deletions xpcom/io/nsStorageStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#include "nsSegmentedBuffer.h"
#include "nsStreamUtils.h"
#include "nsCOMPtr.h"
#include "prbit.h"
#include "nsIInputStream.h"
#include "nsISeekableStream.h"
#include "prlog.h"
#include "mozilla/Attributes.h"
#include "mozilla/Likely.h"
#include "mozilla/MathAlgorithms.h"

#if defined(PR_LOGGING)
//
Expand Down Expand Up @@ -72,7 +72,7 @@ nsStorageStream::Init(uint32_t segmentSize, uint32_t maxSize,
return NS_ERROR_OUT_OF_MEMORY;

mSegmentSize = segmentSize;
mSegmentSizeLog2 = PR_FloorLog2(segmentSize);
mSegmentSizeLog2 = mozilla::FloorLog2(segmentSize);

// Segment size must be a power of two
if (mSegmentSize != ((uint32_t)1 << mSegmentSizeLog2))
Expand Down

0 comments on commit 381cef1

Please sign in to comment.