Skip to content

Commit 42de859

Browse files
andimachovecwaddlesplash
authored andcommitted
fixed -Wpessimizing-move warnings
1 parent 0fffb77 commit 42de859

File tree

3 files changed

+72
-72
lines changed

3 files changed

+72
-72
lines changed

application/DJVUEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,5 +403,5 @@ DJVUEngine::_FindString(BString const& name, int const& page)
403403
}
404404
}
405405

406-
return move(make_tuple(contextVec, rectVec));
406+
return make_tuple(contextVec, rectVec);
407407
}

application/PDFEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ PDFEngine::_FindString(BString const& name, int const& pageNumber)
248248
fz_rethrow(fContext);
249249
}
250250

251-
return move(make_tuple(contextVec, rectVec));
251+
return make_tuple(contextVec, rectVec);
252252
}
253253

254254

application/Tools.h

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -35,64 +35,64 @@ class Tools {
3535
{
3636
app_info info;
3737
be_app->GetAppInfo(&info);
38-
38+
3939
BPath path = BPath(&info.ref);
4040
path.GetParent(&path);
41-
41+
4242
return path.Path();
4343
}
44-
45-
44+
45+
4646
static BString
4747
AppName(void)
4848
{
4949
app_info info;
5050
be_app->GetAppInfo(&info);
51-
51+
5252
BPath path = BPath(&info.ref);
5353
path.GetParent(&path);
54-
54+
5555
return path.Leaf();
5656
}
57-
58-
57+
58+
5959
static BString
6060
SettingsPath(void)
6161
{
6262
BPath path;
6363
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
6464
return "";
65-
65+
6666
path.Append(AppName().Capitalize());
6767
create_directory(path.Path(), 0755);
68-
68+
6969
BString str(path.Path());
7070
str.Append("/");
71-
return str;
71+
return str;
7272
}
73-
74-
73+
74+
7575
static std::vector<BString>
7676
Split(BString str, const char token, BString start = "", BString stop = "")
7777
{
7878
std::vector<BString> vec;
79-
79+
8080
int n1 = 0;
8181
int n2 = str.Length();
82-
82+
8383
if (start != "")
8484
n1 = str.FindFirst(start, 0);
85-
85+
8686
if (stop != "")
8787
n2 = str.FindFirst(stop, n1 + 1);
88-
88+
8989
if (n1 == B_ERROR || n2 == B_ERROR)
9090
return vec;
91-
91+
9292
n1 = n1 + start.Length();
93-
93+
9494
int n = n1;
95-
95+
9696
for (; n < n2; ++n)
9797
if (str[n] == token) {
9898
if (n > 0 && str[n-1] != token) {
@@ -105,39 +105,39 @@ class Tools {
105105
n1 = n + 1;
106106
}
107107
}
108-
108+
109109
char temp[n - n1 + 1] ;
110110
str.CopyInto(temp, n1, n - n1);
111111
temp[n - n1] = '\0';
112112
vec.push_back(temp);
113113
return vec;
114114
}
115-
116-
115+
116+
117117
static std::vector<BString>
118118
Split(unsigned int length, BString str,
119119
const char token, BString start, BString stop)
120120
{
121121
std::vector<BString> vec;
122-
122+
123123
int n1 = 0;
124124
int n2 = str.Length();
125-
125+
126126
if (start != "")
127127
n1 = str.FindFirst(start, 0);
128-
128+
129129
if (stop != "")
130130
n2 = str.FindFirst(stop, n1 + 1);
131-
131+
132132
if (n1 == B_ERROR || n2 == B_ERROR) {
133133
vec.resize(length, "");
134134
return vec;
135135
}
136-
136+
137137
n1 = n1 + start.Length();
138-
138+
139139
int n = n1;
140-
140+
141141
for (; n < n2; ++n)
142142
if (str[n] == token) {
143143
if (n > 0 && str[n-1] != token) {
@@ -147,60 +147,60 @@ class Tools {
147147
vec.push_back(temp);
148148
if (vec.size() == length)
149149
return vec;
150-
150+
151151
n1 = n + 1;
152152
} else {
153153
n1 = n + 1;
154154
}
155155
}
156-
156+
157157
char temp[n - n1 + 1] ;
158158
str.CopyInto(temp, n1, n - n1);
159159
temp[n - n1] = '\0';
160160
vec.push_back(temp);
161161
vec.resize(length, "");
162-
162+
163163
return vec;
164164
}
165-
166-
165+
166+
167167
static BString
168168
Find(BString str, BString searchStr)
169169
{
170170
BString result = "";
171-
171+
172172
if (str.Length() == 0 || searchStr.Length() == 0)
173173
return result;
174-
174+
175175
int n1 = str.FindFirst(searchStr) + searchStr.Length();
176176
int n2 = str.FindFirst(" ", n1);
177-
177+
178178
if (n2 == B_ERROR)
179179
n2 = str.Length();
180-
180+
181181
str.CopyInto(result, n1, n2 - n1);
182-
182+
183183
return result;
184184
}
185-
186-
185+
186+
187187
static BBitmap*
188188
LoadBitmap(BString const& imageName, int size)
189189
{
190190
BResources* res = be_app->AppResources();
191-
191+
192192
if (res == nullptr)
193193
return nullptr;
194-
194+
195195
size_t nbytes = 0;
196196
color_space cspace = B_RGBA32;
197-
197+
198198
const void* data = res->LoadResource('HVIF', imageName.String(), &nbytes);
199-
199+
200200
// size--;
201-
201+
202202
BBitmap* bitmap = new BBitmap(BRect(0, 0, size, size), cspace);
203-
203+
204204
if (bitmap->InitCheck() != B_OK) {
205205
delete bitmap;
206206
bitmap = nullptr;
@@ -209,12 +209,12 @@ class Tools {
209209
delete bitmap;
210210
bitmap = nullptr;
211211
}
212-
212+
213213
res->RemoveResource(data);
214214
return bitmap;
215215
}
216-
217-
216+
217+
218218
static void
219219
ExportBitmap(BBitmap* bitmap,
220220
BString const& path, int32 const& format = B_PNG_FORMAT)
@@ -225,64 +225,64 @@ class Tools {
225225
roster->Translate(&stream, NULL, NULL, &imageFile, B_PNG_FORMAT);
226226
BBitmap* bmp;
227227
stream.DetachBitmap(&bmp);
228-
228+
229229
}
230-
230+
231231

232232
static std::unique_ptr<BBitmap>
233233
RescaleBitmap(std::unique_ptr<BBitmap> src, int32 width, int32 height)
234234
{
235235
if (src == nullptr || src->IsValid() == false)
236236
throw "Tools::RescaleBitmap";
237-
237+
238238
if (height <= 0) {
239239
if (width <= 0)
240240
return src;
241-
242-
height = (width * src->Bounds().Height()) / src->Bounds().Width();
241+
242+
height = (width * src->Bounds().Height()) / src->Bounds().Width();
243243
} else if (width <= 0) {
244244
if (height <= 0)
245245
return src;
246-
246+
247247
width = (height * src->Bounds().Width()) / src->Bounds().Height();
248248
}
249-
249+
250250
BRect srcSize = src->Bounds();
251-
251+
252252
if (height < 0) {
253253
float srcProp = srcSize.Height()/srcSize.Width();
254254
height = (int32)(width * ceil(srcProp));
255255
}
256-
256+
257257
BBitmap* res = new BBitmap(BRect(0, 0, (float)width, (float)height),
258258
src->ColorSpace());
259-
259+
260260
float dx = (srcSize.Width() + 1)/(float)(width + 1);
261261
float dy = (srcSize.Height() + 1)/(float)(height + 1);
262262
uint8 bpp = (uint8)(src->BytesPerRow()/ceil(srcSize.Width()));
263-
263+
264264
int srcYOff = src->BytesPerRow();
265265
int dstYOff = res->BytesPerRow();
266-
266+
267267
void* dstData = res->Bits();
268268
void* srcData = src->Bits();
269-
269+
270270
for (int32 y = 0; y <= height; y++) {
271271
void* dstRow = (void*)((uintptr_t)dstData + (uintptr_t)(y * dstYOff));
272272
void* srcRow = (void*)((uintptr_t)srcData + ((uintptr_t)(y * dy) * srcYOff));
273-
273+
274274
for (int32 x = 0; x <= width; x++)
275275
memcpy((void*)((uintptr_t)dstRow + (x * bpp)), (void*)((uintptr_t)srcRow
276276
+ ((uintptr_t)(x * dx) * bpp)), bpp);
277277
}
278-
278+
279279
std::unique_ptr<BBitmap> bitmap(res);
280-
return move(bitmap);
281-
}
280+
return bitmap;
281+
}
282+
282283

283-
284284
private:
285-
Tools(void);
285+
Tools(void);
286286
};
287287

288288
#endif

0 commit comments

Comments
 (0)