Skip to content

Commit

Permalink
use StrVec2 instead of StrVec; more *Temp() use
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed May 22, 2024
1 parent 93f6738 commit 0539984
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/EbookDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ char* NormalizeURL(const char* url, const char* base) {
} else {
baseEnd = base;
}
AutoFreeStr basePath = str::Dup(base, baseEnd - base);
AutoFreeStr norm = str::Join(basePath, url);
TempStr basePath = str::DupTemp(base, baseEnd - base);
char* norm = str::Join(basePath, url);

char* dst = norm;
for (char* src = norm; *src; src++) {
Expand All @@ -146,7 +146,7 @@ char* NormalizeURL(const char* url, const char* base) {
}
}
*dst = '\0';
return norm.Release();
return norm;
}

inline char decode64(char c) {
Expand Down
2 changes: 1 addition & 1 deletion src/EngineMupdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,7 @@ bool EngineMupdf::Load(const char* path, PasswordUI* pwdUI) {
fz_stream* file = fz_open_buffer(ctx, buf);
fz_drop_buffer(ctx, buf);
str::Free(d);
char* nameHint = str::Join(path, ".html");
TempStr nameHint = str::JoinTemp(path, ".html");
if (!LoadFromStream(file, nameHint, pwdUI)) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/PdfSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ bool Synchronizer::NeedsToRebuildIndex() const {

int Synchronizer::MarkIndexWasRebuilt() {
needsToRebuildIndex = false;
WCHAR* path = ToWStrTemp(syncFilePath);
TempWStr path = ToWStrTemp(syncFilePath);
_wstat(path, &syncfileTimestamp);
return PDFSYNCERR_SUCCESS;
}

char* Synchronizer::PrependDir(const char* filename) const {
char* dir = path::GetDirTemp(syncFilePath);
TempStr dir = path::GetDirTemp(syncFilePath);
return path::Join(dir, filename);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Translations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static void ParseTranslationsTxt(const ByteSlice& d, const char* langCode) {

// parse into lines
char* s = (char*)d.data();
StrVec lines;
StrVec2 lines;
Split(lines, s, "\n", true);
int nStrings = 0;
for (char* l : lines) {
Expand Down
1 change: 0 additions & 1 deletion src/scratch.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Ideas for refactorings:

- change all size_t => int
- remove all use of _TR( : 26 matches (was 48, 61, 74, 94, 141)
- change use of Str::Get() => Str::CStr() (or maybe make it Str() as in StrSpan?)
- audit all str::Join() and path::Join() to see if could / should be *Temp()

Expand Down

0 comments on commit 0539984

Please sign in to comment.