Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Issue 1114313006: Make constructors recognize char[n] vs. char* and avoid strlen calls. (Closed)

Created:
5 years, 7 months ago by Tom Sepez
Modified:
5 years ago
Reviewers:
Lei Zhang, brucedawson
CC:
pdfium-reviews_googlegroups.com
Base URL:
https://pdfium.googlesource.com/pdfium.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Make constructors recognize const char[n] vs. char* and avoid strlen calls. Not an issue for bytestrings, but for widestrings, the compiler doesn't seem to optimize wcslen() calls away.

Patch Set 1 #

Patch Set 2 : deal with stack buffers, etc. #

Patch Set 3 : Delegated constructors everywhere. #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+149 lines, -25 lines) Patch
M core/include/fxcrt/fx_string.h View 1 2 5 chunks +64 lines, -14 lines 1 comment Download
M core/src/fpdfdoc/doc_basic.cpp View 1 chunk +1 line, -1 line 0 comments Download
M core/src/fpdfdoc/doc_metadata.cpp View 2 chunks +9 lines, -9 lines 0 comments Download
M core/src/fxcrt/fx_basic_bstring_unittest.cpp View 1 2 chunks +41 lines, -1 line 0 comments Download
M core/src/fxcrt/fx_basic_wstring_unittest.cpp View 1 2 chunks +34 lines, -0 lines 0 comments Download

Messages

Total messages: 4 (1 generated)
Tom Sepez
We may need to reconsider this. Discuss amongst yourselves.
5 years ago (2015-12-15 00:20:11 UTC) #2
Tom Sepez
We may need to reconsider this. Discuss amongst yourselves.
5 years ago (2015-12-15 00:20:25 UTC) #3
brucedawson
5 years ago (2015-12-15 00:45:10 UTC) #4
https://codereview.chromium.org/1114313006/diff/40001/core/include/fxcrt/fx_s...
File core/include/fxcrt/fx_string.h (right):

https://codereview.chromium.org/1114313006/diff/40001/core/include/fxcrt/fx_s...
core/include/fxcrt/fx_string.h:56: : CFX_ByteStringC(ptr, N - 1) { }
I don't think we have any guarantee that this is a literal. It could simply be
an array that is const. This won't happen often because arrays that are only
partially filled cannot (practically speaking) be const, but they can become
const, by passing them to a function which takes a const array and then that
function passing them to CFX_ByteString.

Powered by Google App Engine
This is Rietveld 408576698