Commit 245ca280665ebeed9cf77b667181e2b0843f8740

Authored by Jay Berkenbilt
1 parent addd6bef

Use value rather than reference captures where possible

Showing 1 changed file with 27 additions and 27 deletions
libqpdf/qpdf-c.cc
... ... @@ -895,7 +895,7 @@ static RET trap_oh_errors(
895 895 // unless needed. This is important because sometimes the fallback
896 896 // creates an object.
897 897 RET ret;
898   - QPDF_ERROR_CODE status = trap_errors(qpdf, [&ret, &fn] (qpdf_data q) {
  898 + QPDF_ERROR_CODE status = trap_errors(qpdf, [&ret, fn] (qpdf_data q) {
899 899 ret = fn(q);
900 900 });
901 901 if (status & QPDF_ERRORS)
... ... @@ -985,7 +985,7 @@ static RET do_with_oh(
985 985 std::function<RET(QPDFObjectHandle&)> fn)
986 986 {
987 987 return trap_oh_errors<RET>(
988   - qpdf, fallback, [&fn, &oh](qpdf_data q) {
  988 + qpdf, fallback, [fn, oh](qpdf_data q) {
989 989 auto i = q->oh_cache.find(oh);
990 990 bool result = ((i != q->oh_cache.end()) &&
991 991 (i->second).getPointer());
... ... @@ -1008,7 +1008,7 @@ static void do_with_oh_void(
1008 1008 std::function<void(QPDFObjectHandle&)> fn)
1009 1009 {
1010 1010 do_with_oh<bool>(
1011   - qpdf, oh, return_T<bool>(false), [&fn](QPDFObjectHandle& o) {
  1011 + qpdf, oh, return_T<bool>(false), [fn](QPDFObjectHandle& o) {
1012 1012 fn(o);
1013 1013 return true; // unused
1014 1014 });
... ... @@ -1017,7 +1017,7 @@ static void do_with_oh_void(
1017 1017 void qpdf_replace_object(qpdf_data qpdf, int objid, int generation, qpdf_oh oh)
1018 1018 {
1019 1019 do_with_oh_void(
1020   - qpdf, oh, [&qpdf, &objid, &generation](QPDFObjectHandle& o) {
  1020 + qpdf, oh, [qpdf, objid, generation](QPDFObjectHandle& o) {
1021 1021 QTC::TC("qpdf", "qpdf-c called qpdf_replace_object");
1022 1022 qpdf->qpdf->replaceObject(objid, generation, o);
1023 1023 });
... ... @@ -1162,8 +1162,8 @@ qpdf_oh qpdf_oh_wrap_in_array(qpdf_data qpdf, qpdf_oh oh)
1162 1162 {
1163 1163 return do_with_oh<qpdf_oh>(
1164 1164 qpdf, oh,
1165   - [&qpdf](){ return qpdf_oh_new_array(qpdf); },
1166   - [&qpdf](QPDFObjectHandle& qoh) {
  1165 + [qpdf](){ return qpdf_oh_new_array(qpdf); },
  1166 + [qpdf](QPDFObjectHandle& qoh) {
1167 1167 if (qoh.isArray())
1168 1168 {
1169 1169 QTC::TC("qpdf", "qpdf-c array to wrap_in_array");
... ... @@ -1183,7 +1183,7 @@ qpdf_oh qpdf_oh_parse(qpdf_data qpdf, char const* object_str)
1183 1183 {
1184 1184 QTC::TC("qpdf", "qpdf-c called qpdf_oh_parse");
1185 1185 return trap_oh_errors<qpdf_oh>(
1186   - qpdf, return_uninitialized(qpdf), [&object_str] (qpdf_data q) {
  1186 + qpdf, return_uninitialized(qpdf), [object_str] (qpdf_data q) {
1187 1187 return new_object(q, QPDFObjectHandle::parse(object_str));
1188 1188 });
1189 1189 }
... ... @@ -1236,7 +1236,7 @@ unsigned int qpdf_oh_get_uint_value_as_uint(qpdf_data qpdf, qpdf_oh oh)
1236 1236 char const* qpdf_oh_get_real_value(qpdf_data qpdf, qpdf_oh oh)
1237 1237 {
1238 1238 return do_with_oh<char const*>(
1239   - qpdf, oh, return_T<char const*>(""), [&qpdf](QPDFObjectHandle& o) {
  1239 + qpdf, oh, return_T<char const*>(""), [qpdf](QPDFObjectHandle& o) {
1240 1240 QTC::TC("qpdf", "qpdf-c called qpdf_oh_get_real_value");
1241 1241 qpdf->tmp_string = o.getRealValue();
1242 1242 return qpdf->tmp_string.c_str();
... ... @@ -1255,7 +1255,7 @@ double qpdf_oh_get_numeric_value(qpdf_data qpdf, qpdf_oh oh)
1255 1255 char const* qpdf_oh_get_name(qpdf_data qpdf, qpdf_oh oh)
1256 1256 {
1257 1257 return do_with_oh<char const*>(
1258   - qpdf, oh, return_T<char const*>(""), [&qpdf](QPDFObjectHandle& o) {
  1258 + qpdf, oh, return_T<char const*>(""), [qpdf](QPDFObjectHandle& o) {
1259 1259 QTC::TC("qpdf", "qpdf-c called qpdf_oh_get_name");
1260 1260 qpdf->tmp_string = o.getName();
1261 1261 return qpdf->tmp_string.c_str();
... ... @@ -1265,7 +1265,7 @@ char const* qpdf_oh_get_name(qpdf_data qpdf, qpdf_oh oh)
1265 1265 char const* qpdf_oh_get_string_value(qpdf_data qpdf, qpdf_oh oh)
1266 1266 {
1267 1267 return do_with_oh<char const*>(
1268   - qpdf, oh, return_T<char const*>(""), [&qpdf](QPDFObjectHandle& o) {
  1268 + qpdf, oh, return_T<char const*>(""), [qpdf](QPDFObjectHandle& o) {
1269 1269 QTC::TC("qpdf", "qpdf-c called qpdf_oh_get_string_value");
1270 1270 qpdf->tmp_string = o.getStringValue();
1271 1271 return qpdf->tmp_string.c_str();
... ... @@ -1275,7 +1275,7 @@ char const* qpdf_oh_get_string_value(qpdf_data qpdf, qpdf_oh oh)
1275 1275 char const* qpdf_oh_get_utf8_value(qpdf_data qpdf, qpdf_oh oh)
1276 1276 {
1277 1277 return do_with_oh<char const*>(
1278   - qpdf, oh, return_T<char const*>(""), [&qpdf](QPDFObjectHandle& o) {
  1278 + qpdf, oh, return_T<char const*>(""), [qpdf](QPDFObjectHandle& o) {
1279 1279 QTC::TC("qpdf", "qpdf-c called qpdf_oh_get_utf8_value");
1280 1280 qpdf->tmp_string = o.getUTF8Value();
1281 1281 return qpdf->tmp_string.c_str();
... ... @@ -1294,7 +1294,7 @@ int qpdf_oh_get_array_n_items(qpdf_data qpdf, qpdf_oh oh)
1294 1294 qpdf_oh qpdf_oh_get_array_item(qpdf_data qpdf, qpdf_oh oh, int n)
1295 1295 {
1296 1296 return do_with_oh<qpdf_oh>(
1297   - qpdf, oh, return_null(qpdf), [&qpdf, &n](QPDFObjectHandle& o) {
  1297 + qpdf, oh, return_null(qpdf), [qpdf, n](QPDFObjectHandle& o) {
1298 1298 QTC::TC("qpdf", "qpdf-c called qpdf_oh_get_array_item");
1299 1299 return new_object(qpdf, o.getArrayItem(n));
1300 1300 });
... ... @@ -1336,7 +1336,7 @@ char const* qpdf_oh_dict_next_key(qpdf_data qpdf)
1336 1336 QPDF_BOOL qpdf_oh_has_key(qpdf_data qpdf, qpdf_oh oh, char const* key)
1337 1337 {
1338 1338 return do_with_oh<QPDF_BOOL>(
1339   - qpdf, oh, return_false, [&key](QPDFObjectHandle& o) {
  1339 + qpdf, oh, return_false, [key](QPDFObjectHandle& o) {
1340 1340 QTC::TC("qpdf", "qpdf-c called qpdf_oh_has_key");
1341 1341 return o.hasKey(key);
1342 1342 });
... ... @@ -1345,7 +1345,7 @@ QPDF_BOOL qpdf_oh_has_key(qpdf_data qpdf, qpdf_oh oh, char const* key)
1345 1345 qpdf_oh qpdf_oh_get_key(qpdf_data qpdf, qpdf_oh oh, char const* key)
1346 1346 {
1347 1347 return do_with_oh<qpdf_oh>(
1348   - qpdf, oh, return_null(qpdf), [&qpdf, &key](QPDFObjectHandle& o) {
  1348 + qpdf, oh, return_null(qpdf), [qpdf, key](QPDFObjectHandle& o) {
1349 1349 QTC::TC("qpdf", "qpdf-c called qpdf_oh_get_key");
1350 1350 return new_object(qpdf, o.getKey(key));
1351 1351 });
... ... @@ -1354,7 +1354,7 @@ qpdf_oh qpdf_oh_get_key(qpdf_data qpdf, qpdf_oh oh, char const* key)
1354 1354 QPDF_BOOL qpdf_oh_is_or_has_name(qpdf_data qpdf, qpdf_oh oh, char const* key)
1355 1355 {
1356 1356 return do_with_oh<QPDF_BOOL>(
1357   - qpdf, oh, return_false, [&key](QPDFObjectHandle& o) {
  1357 + qpdf, oh, return_false, [key](QPDFObjectHandle& o) {
1358 1358 QTC::TC("qpdf", "qpdf-c called qpdf_oh_is_or_has_name");
1359 1359 return o.isOrHasName(key);
1360 1360 });
... ... @@ -1441,7 +1441,7 @@ qpdf_oh qpdf_make_indirect_object(qpdf_data qpdf, qpdf_oh oh)
1441 1441 return do_with_oh<qpdf_oh>(
1442 1442 qpdf, oh,
1443 1443 return_uninitialized(qpdf),
1444   - [&qpdf](QPDFObjectHandle& o) {
  1444 + [qpdf](QPDFObjectHandle& o) {
1445 1445 return new_object(qpdf, qpdf->qpdf->makeIndirectObject(o));
1446 1446 });
1447 1447 }
... ... @@ -1461,7 +1461,7 @@ void qpdf_oh_set_array_item(qpdf_data qpdf, qpdf_oh oh,
1461 1461 int at, qpdf_oh item)
1462 1462 {
1463 1463 do_with_oh_void(
1464   - qpdf, oh, [&qpdf, &at, &item](QPDFObjectHandle& o) {
  1464 + qpdf, oh, [qpdf, at, item](QPDFObjectHandle& o) {
1465 1465 QTC::TC("qpdf", "qpdf-c called qpdf_oh_set_array_item");
1466 1466 o.setArrayItem(at, qpdf_oh_item_internal(qpdf, item));
1467 1467 });
... ... @@ -1470,7 +1470,7 @@ void qpdf_oh_set_array_item(qpdf_data qpdf, qpdf_oh oh,
1470 1470 void qpdf_oh_insert_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item)
1471 1471 {
1472 1472 do_with_oh_void(
1473   - qpdf, oh, [&qpdf, &at, &item](QPDFObjectHandle& o) {
  1473 + qpdf, oh, [qpdf, at, item](QPDFObjectHandle& o) {
1474 1474 QTC::TC("qpdf", "qpdf-c called qpdf_oh_insert_item");
1475 1475 o.insertItem(at, qpdf_oh_item_internal(qpdf, item));
1476 1476 });
... ... @@ -1479,7 +1479,7 @@ void qpdf_oh_insert_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item)
1479 1479 void qpdf_oh_append_item(qpdf_data qpdf, qpdf_oh oh, qpdf_oh item)
1480 1480 {
1481 1481 do_with_oh_void(
1482   - qpdf, oh, [&qpdf, &item](QPDFObjectHandle& o) {
  1482 + qpdf, oh, [qpdf, item](QPDFObjectHandle& o) {
1483 1483 QTC::TC("qpdf", "qpdf-c called qpdf_oh_append_item");
1484 1484 o.appendItem(qpdf_oh_item_internal(qpdf, item));
1485 1485 });
... ... @@ -1488,7 +1488,7 @@ void qpdf_oh_append_item(qpdf_data qpdf, qpdf_oh oh, qpdf_oh item)
1488 1488 void qpdf_oh_erase_item(qpdf_data qpdf, qpdf_oh oh, int at)
1489 1489 {
1490 1490 do_with_oh_void(
1491   - qpdf, oh, [&at](QPDFObjectHandle& o) {
  1491 + qpdf, oh, [at](QPDFObjectHandle& o) {
1492 1492 QTC::TC("qpdf", "qpdf-c called qpdf_oh_erase_item");
1493 1493 o.eraseItem(at);
1494 1494 });
... ... @@ -1498,7 +1498,7 @@ void qpdf_oh_replace_key(qpdf_data qpdf, qpdf_oh oh,
1498 1498 char const* key, qpdf_oh item)
1499 1499 {
1500 1500 do_with_oh_void(
1501   - qpdf, oh, [&qpdf, &key, &item](QPDFObjectHandle& o) {
  1501 + qpdf, oh, [qpdf, key, item](QPDFObjectHandle& o) {
1502 1502 QTC::TC("qpdf", "qpdf-c called qpdf_oh_replace_key");
1503 1503 o.replaceKey(key, qpdf_oh_item_internal(qpdf, item));
1504 1504 });
... ... @@ -1507,7 +1507,7 @@ void qpdf_oh_replace_key(qpdf_data qpdf, qpdf_oh oh,
1507 1507 void qpdf_oh_remove_key(qpdf_data qpdf, qpdf_oh oh, char const* key)
1508 1508 {
1509 1509 do_with_oh_void(
1510   - qpdf, oh, [&key](QPDFObjectHandle& o) {
  1510 + qpdf, oh, [key](QPDFObjectHandle& o) {
1511 1511 QTC::TC("qpdf", "qpdf-c called qpdf_oh_remove_key");
1512 1512 o.removeKey(key);
1513 1513 });
... ... @@ -1517,7 +1517,7 @@ void qpdf_oh_replace_or_remove_key(qpdf_data qpdf, qpdf_oh oh,
1517 1517 char const* key, qpdf_oh item)
1518 1518 {
1519 1519 do_with_oh_void(
1520   - qpdf, oh, [&qpdf, &key, &item](QPDFObjectHandle& o) {
  1520 + qpdf, oh, [qpdf, key, item](QPDFObjectHandle& o) {
1521 1521 QTC::TC("qpdf", "qpdf-c called qpdf_oh_replace_or_remove_key");
1522 1522 o.replaceOrRemoveKey(key, qpdf_oh_item_internal(qpdf, item));
1523 1523 });
... ... @@ -1526,7 +1526,7 @@ void qpdf_oh_replace_or_remove_key(qpdf_data qpdf, qpdf_oh oh,
1526 1526 qpdf_oh qpdf_oh_get_dict(qpdf_data qpdf, qpdf_oh oh)
1527 1527 {
1528 1528 return do_with_oh<qpdf_oh>(
1529   - qpdf, oh, return_null(qpdf), [&qpdf](QPDFObjectHandle& o) {
  1529 + qpdf, oh, return_null(qpdf), [qpdf](QPDFObjectHandle& o) {
1530 1530 QTC::TC("qpdf", "qpdf-c called qpdf_oh_get_dict");
1531 1531 return new_object(qpdf, o.getDict());
1532 1532 });
... ... @@ -1553,7 +1553,7 @@ int qpdf_oh_get_generation(qpdf_data qpdf, qpdf_oh oh)
1553 1553 char const* qpdf_oh_unparse(qpdf_data qpdf, qpdf_oh oh)
1554 1554 {
1555 1555 return do_with_oh<char const*>(
1556   - qpdf, oh, return_T<char const*>(""), [&qpdf](QPDFObjectHandle& o) {
  1556 + qpdf, oh, return_T<char const*>(""), [qpdf](QPDFObjectHandle& o) {
1557 1557 QTC::TC("qpdf", "qpdf-c called qpdf_oh_unparse");
1558 1558 qpdf->tmp_string = o.unparse();
1559 1559 return qpdf->tmp_string.c_str();
... ... @@ -1563,7 +1563,7 @@ char const* qpdf_oh_unparse(qpdf_data qpdf, qpdf_oh oh)
1563 1563 char const* qpdf_oh_unparse_resolved(qpdf_data qpdf, qpdf_oh oh)
1564 1564 {
1565 1565 return do_with_oh<char const*>(
1566   - qpdf, oh, return_T<char const*>(""), [&qpdf](QPDFObjectHandle& o) {
  1566 + qpdf, oh, return_T<char const*>(""), [qpdf](QPDFObjectHandle& o) {
1567 1567 QTC::TC("qpdf", "qpdf-c called qpdf_oh_unparse_resolved");
1568 1568 qpdf->tmp_string = o.unparseResolved();
1569 1569 return qpdf->tmp_string.c_str();
... ... @@ -1573,7 +1573,7 @@ char const* qpdf_oh_unparse_resolved(qpdf_data qpdf, qpdf_oh oh)
1573 1573 char const* qpdf_oh_unparse_binary(qpdf_data qpdf, qpdf_oh oh)
1574 1574 {
1575 1575 return do_with_oh<char const*>(
1576   - qpdf, oh, return_T<char const*>(""), [&qpdf](QPDFObjectHandle& o) {
  1576 + qpdf, oh, return_T<char const*>(""), [qpdf](QPDFObjectHandle& o) {
1577 1577 QTC::TC("qpdf", "qpdf-c called qpdf_oh_unparse_binary");
1578 1578 qpdf->tmp_string = o.unparseBinary();
1579 1579 return qpdf->tmp_string.c_str();
... ...