Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
fc8237e6
Commit
fc8237e6
authored
4 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Clean up mountains of string temporaries from LLDiskCache::metaDataToFilepath
parent
16f26f55
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
indra/llfilesystem/lldiskcache.cpp
+9
-8
9 additions, 8 deletions
indra/llfilesystem/lldiskcache.cpp
indra/llfilesystem/lldiskcache.h
+2
-3
2 additions, 3 deletions
indra/llfilesystem/lldiskcache.h
indra/llfilesystem/llfilesystem.cpp
+8
-29
8 additions, 29 deletions
indra/llfilesystem/llfilesystem.cpp
with
19 additions
and
40 deletions
indra/llfilesystem/lldiskcache.cpp
+
9
−
8
View file @
fc8237e6
...
@@ -179,11 +179,12 @@ const std::string LLDiskCache::assetTypeToString(LLAssetType::EType at)
...
@@ -179,11 +179,12 @@ const std::string LLDiskCache::assetTypeToString(LLAssetType::EType at)
return
std
::
string
(
"UNKNOWN"
);
return
std
::
string
(
"UNKNOWN"
);
}
}
const
std
::
string
LLDiskCache
::
metaDataToFilepath
(
const
std
::
string
id
,
const
std
::
string
LLDiskCache
::
metaDataToFilepath
(
const
LLUUID
&
id
,
LLAssetType
::
EType
at
,
LLAssetType
::
EType
at
)
const
std
::
string
extra_info
)
{
{
return
llformat
(
"%s%s%s_%s_%s"
,
mCacheDir
.
c_str
(),
gDirUtilp
->
getDirDelimiter
().
c_str
(),
mCacheFilenamePrefix
.
c_str
(),
id
.
c_str
(),
(
extra_info
.
empty
()
?
"0"
:
extra_info
.
c_str
()));
std
::
string
uuidstr
;
id
.
toString
(
uuidstr
);
return
llformat
(
"%s%s%s_%s"
,
mCacheDir
.
c_str
(),
gDirUtilp
->
getDirDelimiter
().
c_str
(),
mCacheFilenamePrefix
.
c_str
(),
uuidstr
.
c_str
());
}
}
void
LLDiskCache
::
updateFileAccessTime
(
const
std
::
string
file_path
)
void
LLDiskCache
::
updateFileAccessTime
(
const
std
::
string
file_path
)
...
@@ -250,9 +251,9 @@ void LLDiskCache::clearCache()
...
@@ -250,9 +251,9 @@ void LLDiskCache::clearCache()
* likely just fine
* likely just fine
*/
*/
#if LL_WINDOWS
#if LL_WINDOWS
st
d
::
wstring
cache_path
(
ll_convert_string_to_wide
(
mCacheDir
));
boo
st
::
filesystem
::
path
cache_path
(
ll_convert_string_to_wide
(
mCacheDir
));
#else
#else
st
d
::
string
cache_path
(
mCacheDir
);
boo
st
::
filesystem
::
path
cache_path
(
mCacheDir
);
#endif
#endif
if
(
boost
::
filesystem
::
is_directory
(
cache_path
))
if
(
boost
::
filesystem
::
is_directory
(
cache_path
))
{
{
...
@@ -283,9 +284,9 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir)
...
@@ -283,9 +284,9 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir)
* is an easy win.
* is an easy win.
*/
*/
#if LL_WINDOWS
#if LL_WINDOWS
st
d
::
wstring
dir_path
(
ll_convert_string_to_wide
(
dir
));
boo
st
::
filesystem
::
path
dir_path
(
ll_convert_string_to_wide
(
dir
));
#else
#else
st
d
::
string
dir_path
(
dir
);
boo
st
::
filesystem
::
path
dir_path
(
dir
);
#endif
#endif
if
(
boost
::
filesystem
::
is_directory
(
dir_path
))
if
(
boost
::
filesystem
::
is_directory
(
dir_path
))
{
{
...
...
This diff is collapsed.
Click to expand it.
indra/llfilesystem/lldiskcache.h
+
2
−
3
View file @
fc8237e6
...
@@ -104,9 +104,8 @@ class LLDiskCache :
...
@@ -104,9 +104,8 @@ class LLDiskCache :
* so many things had to be pushed back there to accomodate it, that I
* so many things had to be pushed back there to accomodate it, that I
* decided to move it here. Still not sure that's completely right.
* decided to move it here. Still not sure that's completely right.
*/
*/
const
std
::
string
metaDataToFilepath
(
const
std
::
string
id
,
const
std
::
string
metaDataToFilepath
(
const
LLUUID
&
id
,
LLAssetType
::
EType
at
,
LLAssetType
::
EType
at
);
const
std
::
string
extra_info
);
/**
/**
* Update the "last write time" of a file to "now". This must be called whenever a
* Update the "last write time" of a file to "now". This must be called whenever a
...
...
This diff is collapsed.
Click to expand it.
indra/llfilesystem/llfilesystem.cpp
+
8
−
29
View file @
fc8237e6
...
@@ -48,10 +48,7 @@ LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_
...
@@ -48,10 +48,7 @@ LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_
// static
// static
bool
LLFileSystem
::
getExists
(
const
LLUUID
&
file_id
,
const
LLAssetType
::
EType
file_type
)
bool
LLFileSystem
::
getExists
(
const
LLUUID
&
file_id
,
const
LLAssetType
::
EType
file_type
)
{
{
std
::
string
id_str
;
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
file_id
,
file_type
);
file_id
.
toString
(
id_str
);
const
std
::
string
extra_info
=
""
;
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
id_str
,
file_type
,
extra_info
);
llifstream
file
(
filename
,
std
::
ios
::
binary
);
llifstream
file
(
filename
,
std
::
ios
::
binary
);
if
(
file
.
is_open
())
if
(
file
.
is_open
())
...
@@ -65,10 +62,7 @@ bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType fil
...
@@ -65,10 +62,7 @@ bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType fil
// static
// static
bool
LLFileSystem
::
removeFile
(
const
LLUUID
&
file_id
,
const
LLAssetType
::
EType
file_type
)
bool
LLFileSystem
::
removeFile
(
const
LLUUID
&
file_id
,
const
LLAssetType
::
EType
file_type
)
{
{
std
::
string
id_str
;
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
file_id
,
file_type
);
file_id
.
toString
(
id_str
);
const
std
::
string
extra_info
=
""
;
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
id_str
,
file_type
,
extra_info
);
LLFile
::
remove
(
filename
.
c_str
());
LLFile
::
remove
(
filename
.
c_str
());
...
@@ -79,14 +73,8 @@ bool LLFileSystem::removeFile(const LLUUID& file_id, const LLAssetType::EType fi
...
@@ -79,14 +73,8 @@ bool LLFileSystem::removeFile(const LLUUID& file_id, const LLAssetType::EType fi
bool
LLFileSystem
::
renameFile
(
const
LLUUID
&
old_file_id
,
const
LLAssetType
::
EType
old_file_type
,
bool
LLFileSystem
::
renameFile
(
const
LLUUID
&
old_file_id
,
const
LLAssetType
::
EType
old_file_type
,
const
LLUUID
&
new_file_id
,
const
LLAssetType
::
EType
new_file_type
)
const
LLUUID
&
new_file_id
,
const
LLAssetType
::
EType
new_file_type
)
{
{
std
::
string
old_id_str
;
const
std
::
string
old_filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
old_file_id
,
old_file_type
);
old_file_id
.
toString
(
old_id_str
);
const
std
::
string
new_filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
new_file_id
,
new_file_type
);
const
std
::
string
extra_info
=
""
;
const
std
::
string
old_filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
old_id_str
,
old_file_type
,
extra_info
);
std
::
string
new_id_str
;
new_file_id
.
toString
(
new_id_str
);
const
std
::
string
new_filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
new_id_str
,
new_file_type
,
extra_info
);
// Rename needs the new file to not exist.
// Rename needs the new file to not exist.
LLFileSystem
::
removeFile
(
new_file_id
,
new_file_type
);
LLFileSystem
::
removeFile
(
new_file_id
,
new_file_type
);
...
@@ -97,7 +85,7 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp
...
@@ -97,7 +85,7 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp
// failed but the original code does not and doing so seems to
// failed but the original code does not and doing so seems to
// break a lot of things so we go with the flow...
// break a lot of things so we go with the flow...
//return FALSE;
//return FALSE;
LL_WARNS
()
<<
"Failed to rename "
<<
old_file_id
<<
" to "
<<
new_
id_str
<<
" reason: "
<<
strerror
(
errno
)
<<
LL_ENDL
;
LL_WARNS
()
<<
"Failed to rename "
<<
old_file_id
<<
" to "
<<
new_
file_id
<<
" reason: "
<<
strerror
(
errno
)
<<
LL_ENDL
;
}
}
return
TRUE
;
return
TRUE
;
...
@@ -106,10 +94,7 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp
...
@@ -106,10 +94,7 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp
// static
// static
S32
LLFileSystem
::
getFileSize
(
const
LLUUID
&
file_id
,
const
LLAssetType
::
EType
file_type
)
S32
LLFileSystem
::
getFileSize
(
const
LLUUID
&
file_id
,
const
LLAssetType
::
EType
file_type
)
{
{
std
::
string
id_str
;
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
file_id
,
file_type
);
file_id
.
toString
(
id_str
);
const
std
::
string
extra_info
=
""
;
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
id_str
,
file_type
,
extra_info
);
S32
file_size
=
0
;
S32
file_size
=
0
;
llifstream
file
(
filename
,
std
::
ios
::
binary
);
llifstream
file
(
filename
,
std
::
ios
::
binary
);
...
@@ -126,10 +111,7 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes)
...
@@ -126,10 +111,7 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes)
{
{
BOOL
success
=
TRUE
;
BOOL
success
=
TRUE
;
std
::
string
id
;
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
mFileID
,
mFileType
);
mFileID
.
toString
(
id
);
const
std
::
string
extra_info
=
""
;
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
id
,
mFileType
,
extra_info
);
llifstream
file
(
filename
,
std
::
ios
::
binary
);
llifstream
file
(
filename
,
std
::
ios
::
binary
);
if
(
file
.
is_open
())
if
(
file
.
is_open
())
...
@@ -177,10 +159,7 @@ BOOL LLFileSystem::eof()
...
@@ -177,10 +159,7 @@ BOOL LLFileSystem::eof()
BOOL
LLFileSystem
::
write
(
const
U8
*
buffer
,
S32
bytes
)
BOOL
LLFileSystem
::
write
(
const
U8
*
buffer
,
S32
bytes
)
{
{
std
::
string
id_str
;
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
mFileID
,
mFileType
);
mFileID
.
toString
(
id_str
);
const
std
::
string
extra_info
=
""
;
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
id_str
,
mFileType
,
extra_info
);
BOOL
success
=
FALSE
;
BOOL
success
=
FALSE
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment