Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 29434561: Noissue - [emscripten] Call the correct constructor for strings created from JavaScript (Closed)

Created:
May 9, 2017, 10:37 a.m. by Wladimir Palant
Modified:
Aug. 23, 2017, 10:44 a.m.
Reviewers:
sergei
CC:
hub, Felix Dahlke
Base URL:
https://hg.adblockplus.org/adblockpluscore
Visibility:
Public.

Description

Current code works mostly by coincidence - it always calls DependentString constructor regardless of whether DependentString or OwnedString instance is being created. With this change we should be calling the right constructor so that we don't run into issues later.

Patch Set 1 #

Total comments: 6

Patch Set 2 : Added comment #

Unified diffs Side-by-side diffs Delta from patch set Stats (+25 lines, -3 lines) Patch
M compiled/bindings/generator.cpp View 1 2 chunks +18 lines, -3 lines 0 comments Download
M compiled/bindings/runtime_utils.cpp View 1 chunk +7 lines, -0 lines 0 comments Download

Messages

Total messages: 5
Wladimir Palant
May 9, 2017, 10:37 a.m. (2017-05-09 10:37:23 UTC) #1
Wladimir Palant
Current code works mostly by coincidence - it always calls DependentString constructor regardless of whether ...
May 9, 2017, 10:39 a.m. (2017-05-09 10:39:30 UTC) #2
sergei
LGTM https://codereview.adblockplus.org/29434561/diff/29434562/compiled/bindings/generator.cpp File compiled/bindings/generator.cpp (right): https://codereview.adblockplus.org/29434561/diff/29434562/compiled/bindings/generator.cpp#newcode230 compiled/bindings/generator.cpp:230: return result; Strictly speaking, despite destructor of DependentString ...
Aug. 23, 2017, 10:06 a.m. (2017-08-23 10:06:16 UTC) #3
Wladimir Palant
https://codereview.adblockplus.org/29434561/diff/29434562/compiled/bindings/generator.cpp File compiled/bindings/generator.cpp (right): https://codereview.adblockplus.org/29434561/diff/29434562/compiled/bindings/generator.cpp#newcode230 compiled/bindings/generator.cpp:230: return result; On 2017/08/23 10:06:15, sergei wrote: > Strictly ...
Aug. 23, 2017, 10:26 a.m. (2017-08-23 10:26:41 UTC) #4
sergei
Aug. 23, 2017, 10:39 a.m. (2017-08-23 10:39:20 UTC) #5
LGTM

https://codereview.adblockplus.org/29434561/diff/29434562/compiled/bindings/g...
File compiled/bindings/generator.cpp (right):

https://codereview.adblockplus.org/29434561/diff/29434562/compiled/bindings/g...
compiled/bindings/generator.cpp:230: return result;
On 2017/08/23 10:26:41, Wladimir Palant wrote:
> On 2017/08/23 10:06:15, sergei wrote:
> > Strictly speaking, despite destructor of DependentString does nothing it is
> > still should be called or we should put a comment here that it's an
> > optimization. It seems another issue, though, but can be done here.
> 
> Ok, I added a comment. In fact, we might need to call the destructor in debug
> mode if we add reference counting.

Yeah, I thought about similar debug needs too. If it's possible we could maybe
have that call optional. The current variant is fine for me, it can be added
when there is a real demand for that.

https://codereview.adblockplus.org/29434561/diff/29434562/compiled/bindings/g...
compiled/bindings/generator.cpp:237: result += "  var result =
readString(string);\n";
On 2017/08/23 10:26:41, Wladimir Palant wrote:
> On 2017/08/23 10:06:15, sergei wrote:
> > Since anyway we have separate calls of Module._InitOwnedString(result); and
> > Module._DestroyString(string); we could move the latter into a readString
> which
> > calls Module._DestroyString(string);. It could save few bytes of JS code.
> 
> I tried that but it makes the code here less obvious IMHO. The few bytes saved
> don't really matter either.

Acknowledged.

Powered by Google App Engine
This is Rietveld