Cleanup: don't unnecessarily use ustring in IES file parsing

This commit is contained in:
Brecht Van Lommel 2019-08-14 14:04:23 +02:00
parent d2195d9ef2
commit 7ae3aa7b63
Notes: blender-bot 2023-02-14 02:30:10 +01:00
Referenced by issue #68647, objects selected using box select cannot be moved to collection if there is no active object
5 changed files with 15 additions and 13 deletions

View File

@ -944,7 +944,7 @@ void LightManager::tag_update(Scene * /*scene*/)
need_update = true;
}
int LightManager::add_ies_from_file(ustring filename)
int LightManager::add_ies_from_file(const string &filename)
{
string content;
@ -953,10 +953,10 @@ int LightManager::add_ies_from_file(ustring filename)
content = "\n";
}
return add_ies(ustring(content));
return add_ies(content);
}
int LightManager::add_ies(ustring content)
int LightManager::add_ies(const string &content)
{
uint hash = hash_string(content.c_str());

View File

@ -92,8 +92,8 @@ class LightManager {
~LightManager();
/* IES texture management */
int add_ies(ustring ies);
int add_ies_from_file(ustring filename);
int add_ies(const string &ies);
int add_ies_from_file(const string &filename);
void remove_ies(int slot);
void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);

View File

@ -1067,10 +1067,10 @@ void IESLightNode::get_slot()
if (slot == -1) {
if (ies.empty()) {
slot = light_manager->add_ies_from_file(filename);
slot = light_manager->add_ies_from_file(filename.string());
}
else {
slot = light_manager->add_ies(ies);
slot = light_manager->add_ies(ies.string());
}
}
}

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <algorithm>
#include "util/util_foreach.h"
#include "util/util_ies.h"
#include "util/util_math.h"
@ -28,7 +30,7 @@ CCL_NAMESPACE_BEGIN
// issue.
template class GuardedAllocator<char>;
bool IESFile::load(ustring ies)
bool IESFile::load(const string &ies)
{
clear();
if (!parse(ies) || !process()) {
@ -76,7 +78,7 @@ class IESTextParser {
vector<char> text;
char *data;
IESTextParser(ustring str) : text(str.begin(), str.end())
IESTextParser(const string &str) : text(str.begin(), str.end())
{
std::replace(text.begin(), text.end(), ',', ' ');
data = strstr(&text[0], "\nTILT=");
@ -116,7 +118,7 @@ class IESTextParser {
}
};
bool IESFile::parse(ustring ies)
bool IESFile::parse(const string &ies)
{
if (ies.empty()) {
return false;

View File

@ -17,7 +17,7 @@
#ifndef __UTIL_IES_H__
#define __UTIL_IES_H__
#include "util/util_param.h"
#include "util/util_string.h"
#include "util/util_vector.h"
CCL_NAMESPACE_BEGIN
@ -32,11 +32,11 @@ class IESFile {
int packed_size();
void pack(float *data);
bool load(ustring ies);
bool load(const string &ies);
void clear();
protected:
bool parse(ustring ies);
bool parse(const string &ies);
bool process();
bool process_type_b();
bool process_type_c();