[Bf-blender-cvs] [7ae3aa7b631] master: Cleanup: don't unnecessarily use ustring in IES file parsing

Brecht Van Lommel noreply at git.blender.org
Wed Aug 14 14:21:11 CEST 2019


Commit: 7ae3aa7b63136ea590004ae2ca765697bf0756bc
Author: Brecht Van Lommel
Date:   Wed Aug 14 14:04:23 2019 +0200
Branches: master
https://developer.blender.org/rB7ae3aa7b63136ea590004ae2ca765697bf0756bc

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

===================================================================

M	intern/cycles/render/light.cpp
M	intern/cycles/render/light.h
M	intern/cycles/render/nodes.cpp
M	intern/cycles/util/util_ies.cpp
M	intern/cycles/util/util_ies.h

===================================================================

diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 5c3f1c35bdc..8c7a21da561 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -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());
 
diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h
index 79450ea5f8d..6dd23374818 100644
--- a/intern/cycles/render/light.h
+++ b/intern/cycles/render/light.h
@@ -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);
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 1a0225e19a8..9255181b421 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -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());
     }
   }
 }
diff --git a/intern/cycles/util/util_ies.cpp b/intern/cycles/util/util_ies.cpp
index 7c24a4ec28c..62d3d42186d 100644
--- a/intern/cycles/util/util_ies.cpp
+++ b/intern/cycles/util/util_ies.cpp
@@ -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;
diff --git a/intern/cycles/util/util_ies.h b/intern/cycles/util/util_ies.h
index ab1b9ea57cf..95473103614 100644
--- a/intern/cycles/util/util_ies.h
+++ b/intern/cycles/util/util_ies.h
@@ -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();



More information about the Bf-blender-cvs mailing list