MCPcopy Create free account
hub / github.com/ararog/Unrar4iOS / CopyString

Method CopyString

Unrar4iOS/unrar/unpack.cpp:81–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79
80
81_forceinline void Unpack::CopyString(uint Length,uint Distance)
82{
83 uint SrcPtr=UnpPtr-Distance;
84 if (SrcPtr<MAXWINSIZE-MAX_LZ_MATCH && UnpPtr<MAXWINSIZE-MAX_LZ_MATCH)
85 {
86 // If we are not close to end of window, we do not need to waste time
87 // to "& MAXWINMASK" pointer protection.
88
89 byte *Src=Window+SrcPtr;
90 byte *Dest=Window+UnpPtr;
91 UnpPtr+=Length;
92
93 while (Length>=8)
94 {
95 // Unroll the loop for 8 byte and longer strings.
96 Dest[0]=Src[0];
97 Dest[1]=Src[1];
98 Dest[2]=Src[2];
99 Dest[3]=Src[3];
100 Dest[4]=Src[4];
101 Dest[5]=Src[5];
102 Dest[6]=Src[6];
103 Dest[7]=Src[7];
104 Src+=8;
105 Dest+=8;
106 Length-=8;
107 }
108
109 // Unroll the loop for 0 - 7 bytes left. Note that we use nested "if"s.
110 if (Length>0) { Dest[0]=Src[0];
111 if (Length>1) { Dest[1]=Src[1];
112 if (Length>2) { Dest[2]=Src[2];
113 if (Length>3) { Dest[3]=Src[3];
114 if (Length>4) { Dest[4]=Src[4];
115 if (Length>5) { Dest[5]=Src[5];
116 if (Length>6) { Dest[6]=Src[6]; } } } } } } } // Close all nested "if"s.
117 }
118 else
119 while (Length--) // Slow copying with all possible precautions.
120 {
121 Window[UnpPtr]=Window[SrcPtr++ & MAXWINMASK];
122 UnpPtr=(UnpPtr+1) & MAXWINMASK;
123 }
124}
125
126
127_forceinline uint Unpack::DecodeNumber(DecodeTable *Dec)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected