summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-11-25 00:07:54 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-11-25 00:09:40 -0300
commitbc2e8d99e5ae0dbd69e712cc71da3033f5f30139 (patch)
treed836011e3d5873e3ceea328ea3100f3c7719ab99 /platform
parent7dfba3cda9f13427f9f10a6eefbec52aef62274c (diff)
Made Vector::ptrw explicit for writing, compiler was sometimes using the wrong function,
leading to unnecesary copy on writes and reduced performance.
Diffstat (limited to 'platform')
-rw-r--r--platform/android/export/export.cpp8
-rw-r--r--platform/iphone/export/export.cpp2
-rw-r--r--platform/javascript/export/export.cpp4
-rw-r--r--platform/osx/export/export.cpp2
-rw-r--r--platform/uwp/export/export.cpp24
5 files changed, 20 insertions, 20 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 3df52f1635..67e00f4952 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -1391,7 +1391,7 @@ public:
//read
unzOpenCurrentFile(pkg);
- unzReadCurrentFile(pkg, data.ptr(), data.size());
+ unzReadCurrentFile(pkg, data.ptrw(), data.size());
unzCloseCurrentFile(pkg);
//write
@@ -1414,7 +1414,7 @@ public:
FileAccess *f = FileAccess::open(icon_path, FileAccess::READ);
if (f) {
data.resize(f->get_len());
- f->get_buffer(data.ptr(), data.size());
+ f->get_buffer(data.ptrw(), data.size());
memdelete(f);
found = true;
break;
@@ -1428,7 +1428,7 @@ public:
FileAccess *f = FileAccess::open(appicon, FileAccess::READ);
if (f) {
data.resize(f->get_len());
- f->get_buffer(data.ptr(), data.size());
+ f->get_buffer(data.ptrw(), data.size());
memdelete(f);
}
}
@@ -1703,7 +1703,7 @@ public:
int method, level;
unzOpenCurrentFile2(tmp_unaligned, &method, &level, 1); // raw read
long file_offset = unzGetCurrentFileZStreamPos64(tmp_unaligned);
- unzReadCurrentFile(tmp_unaligned, data.ptr(), data.size());
+ unzReadCurrentFile(tmp_unaligned, data.ptrw(), data.size());
unzCloseCurrentFile(tmp_unaligned);
// align
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index 6aa1ed9f8d..8ab1cbc435 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -793,7 +793,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
//read
unzOpenCurrentFile(src_pkg_zip);
- unzReadCurrentFile(src_pkg_zip, data.ptr(), data.size());
+ unzReadCurrentFile(src_pkg_zip, data.ptrw(), data.size());
unzCloseCurrentFile(src_pkg_zip);
//write
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index 05b0fb3fbc..775e9c7ee0 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -214,7 +214,7 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
//read
unzOpenCurrentFile(pkg);
- unzReadCurrentFile(pkg, data.ptr(), data.size());
+ unzReadCurrentFile(pkg, data.ptrw(), data.size());
unzCloseCurrentFile(pkg);
//write
@@ -257,7 +257,7 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
}
Vector<uint8_t> buf;
buf.resize(f->get_len());
- f->get_buffer(buf.ptr(), buf.size());
+ f->get_buffer(buf.ptrw(), buf.size());
memdelete(f);
_fix_html(buf, p_preset, p_path.get_file().get_basename(), p_debug);
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index 689b79b826..8091a38adb 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -390,7 +390,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
//read
unzOpenCurrentFile(src_pkg_zip);
- unzReadCurrentFile(src_pkg_zip, data.ptr(), data.size());
+ unzReadCurrentFile(src_pkg_zip, data.ptrw(), data.size());
unzCloseCurrentFile(src_pkg_zip);
//write
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 120df9bc3f..7f86b4ae53 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -137,7 +137,7 @@ class AppxPackager {
ZPOS64_T end_of_central_dir_offset;
Vector<uint8_t> central_dir_data;
- String hash_block(uint8_t *p_block_data, size_t p_block_len);
+ String hash_block(const uint8_t *p_block_data, size_t p_block_len);
void make_block_map();
void make_content_types();
@@ -188,14 +188,14 @@ public:
///////////////////////////////////////////////////////////////////////////
-String AppxPackager::hash_block(uint8_t *p_block_data, size_t p_block_len) {
+String AppxPackager::hash_block(const uint8_t *p_block_data, size_t p_block_len) {
char hash[32];
char base64[45];
sha256_context ctx;
sha256_init(&ctx);
- sha256_hash(&ctx, p_block_data, p_block_len);
+ sha256_hash(&ctx, (uint8_t *)p_block_data, p_block_len);
sha256_done(&ctx, (uint8_t *)hash);
base64_encode(base64, hash, 32);
@@ -510,8 +510,8 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
strm.avail_in = block_size;
strm.avail_out = strm_out.size();
- strm.next_in = strm_in.ptr();
- strm.next_out = strm_out.ptr();
+ strm.next_in = (uint8_t *)strm_in.ptr();
+ strm.next_out = strm_out.ptrw();
int total_out_before = strm.total_out;
@@ -541,8 +541,8 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
strm.avail_in = 0;
strm.avail_out = strm_out.size();
- strm.next_in = strm_in.ptr();
- strm.next_out = strm_out.ptr();
+ strm.next_in = (uint8_t *)strm_in.ptr();
+ strm.next_out = strm_out.ptrw();
int total_out_before = strm.total_out;
@@ -588,7 +588,7 @@ void AppxPackager::finish() {
Vector<uint8_t> blockmap_buffer;
blockmap_buffer.resize(blockmap_file->get_len());
- blockmap_file->get_buffer(blockmap_buffer.ptr(), blockmap_buffer.size());
+ blockmap_file->get_buffer(blockmap_buffer.ptrw(), blockmap_buffer.size());
add_file("AppxBlockMap.xml", blockmap_buffer.ptr(), blockmap_buffer.size(), -1, -1, true);
@@ -604,7 +604,7 @@ void AppxPackager::finish() {
Vector<uint8_t> types_buffer;
types_buffer.resize(types_file->get_len());
- types_file->get_buffer(types_buffer.ptr(), types_buffer.size());
+ types_file->get_buffer(types_buffer.ptrw(), types_buffer.size());
add_file("[Content_Types].xml", types_buffer.ptr(), types_buffer.size(), -1, -1, true);
@@ -911,7 +911,7 @@ class EditorExportUWP : public EditorExportPlatform {
}
data.resize(f->get_len());
- f->get_buffer(data.ptr(), data.size());
+ f->get_buffer(data.ptrw(), data.size());
f->close();
memdelete(f);
@@ -1301,7 +1301,7 @@ public:
if (do_read) {
data.resize(info.uncompressed_size);
unzOpenCurrentFile(pkg);
- unzReadCurrentFile(pkg, data.ptr(), data.size());
+ unzReadCurrentFile(pkg, data.ptrw(), data.size());
unzCloseCurrentFile(pkg);
}
@@ -1341,7 +1341,7 @@ public:
// Argc
clf.resize(4);
- encode_uint32(cl.size(), clf.ptr());
+ encode_uint32(cl.size(), clf.ptrw());
for (int i = 0; i < cl.size(); i++) {