void MemoryMappedFile::PrefetchRange( Range<const char*> memoryRange ) const {
#	if( WIN8_MEMORY_MAPPED_FILE_AVAILABLE )
		WIN32_MEMORY_RANGE_ENTRY	ranges[] = { { const_cast<char*>( memoryRange.first ), memoryRange.GetSize() } };

		PrefetchVirtualMemory( GetCurrentProcess(), _countof( ranges ), ranges, 0 );
#	else
		for( auto temp( memoryRange.Begin() ); temp < memoryRange.End(); temp += PrefetchStride ) {
		//	TODO: Is it possible to use prefetch instructions to avoid polluting the processor caches?
			register int readTarget = *reinterpret_cast<const int*>(temp);
		}
#	endif
	}
Example #2
0
/*! \brief Looks for a pattern match in the given data stream, starting from
	each offset withing the given range. Returns true is a match is found,
	false if not.
*/
bool
Pattern::Sniff(Range range, BPositionIO *data, bool caseInsensitive) const {
	int32 start = range.Start();
	int32 end = range.End();
	off_t size = data->Seek(0, SEEK_END);
	if (end >= size)
		end = size-1;	// Don't bother searching beyond the end of the stream
	for (int i = start; i <= end; i++) {
		if (Sniff(i, size, data, caseInsensitive))
			return true;
	}
	return false;
}
Example #3
0
bool
ChunkSet::HasSubrange(const Range& aSubrange) const
{
    for (const Range& range : mRanges) {
        if (range.Contains(aSubrange)) {
            return true;
        } else if (!(aSubrange.Begin() > range.End() ||
                     range.Begin() > aSubrange.End())) {
            // In this case, aSubrange overlaps this range but is not a subrange.
            // because the ChunkSet implementation ensures that there are no
            // overlapping ranges, this means that aSubrange cannot be a subrange of
            // any of the following ranges
            return false;
        }
    }

    return false;
}