MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / erase

Method erase

common/SmallString.cpp:791–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

789}
790
791void SmallStringBase::erase(s32 offset, s32 count)
792{
793 // calc real offset
794 u32 real_offset;
795 if (offset < 0)
796 real_offset = static_cast<u32>(std::max<s32>(0, static_cast<s32>(m_length + offset)));
797 else
798 real_offset = std::min((u32)offset, m_length);
799
800 // calc real count
801 u32 real_count;
802 if (count < 0)
803 {
804 real_count =
805 std::min(m_length - real_offset, static_cast<u32>(std::max<s32>(0, static_cast<s32>(m_length) + count)));
806 }
807 else
808 {
809 real_count = std::min(m_length - real_offset, static_cast<u32>(count));
810 }
811
812 // Fastpath: offset == 0, count < 0, wipe whole string.
813 if (real_offset == 0 && real_count == m_length)
814 {
815 clear();
816 return;
817 }
818
819 // Fastpath: offset >= 0, count < 0, wipe everything after offset + count
820 if ((real_offset + real_count) == m_length)
821 {
822 m_length -= real_count;
823#ifdef _DEBUG
824 std::memset(m_buffer + m_length, 0, m_buffer_size - m_length);
825#else
826 m_buffer[m_length] = 0;
827#endif
828 }
829 // Slowpath: offset >= 0, count < length
830 else
831 {
832 const u32 after_erase_block = m_length - real_offset - real_count;
833 pxAssert(after_erase_block > 0);
834
835 std::memmove(m_buffer + offset, m_buffer + real_offset + real_count, after_erase_block);
836 m_length = m_length - real_count;
837
838#ifdef _DEBUG
839 std::memset(m_buffer + m_length, 0, m_buffer_size - m_length);
840#else
841 m_buffer[m_length] = 0;
842#endif
843 }
844}

Callers 15

ParseZipMethod · 0.45
SetValueMethod · 0.45
SetStringListMethod · 0.45
RemoveFromStringListMethod · 0.45
DeleteValueMethod · 0.45
ClearSectionMethod · 0.45
RemoveSectionMethod · 0.45
RemoveEmptySectionsMethod · 0.45
StripWhitespaceFunction · 0.45
EllipsiseInPlaceFunction · 0.45
LockedPollRequestsMethod · 0.45
EvictMethod · 0.45

Calls 2

minFunction · 0.50
clearFunction · 0.50

Tested by

no test coverage detected