OSDN Git Service

small optimization for SharedMemory
authorsdottaka <none@none>
Sun, 9 Dec 2012 11:19:54 +0000 (20:19 +0900)
committersdottaka <none@none>
Sun, 9 Dec 2012 11:19:54 +0000 (20:19 +0900)
Externals/poco/Foundation/include/Poco/File.h
Externals/poco/Foundation/include/Poco/File_WIN32U.h
Externals/poco/Foundation/src/SharedMemory_WIN32.cpp

index e5d48da..dbd33b5 100644 (file)
@@ -110,6 +110,11 @@ public:
        const std::string& path() const;
                /// Returns the path.
        
+#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
+       const std::wstring& wpath() const;
+               /// Returns the path.
+#endif
+
        bool exists() const;
                /// Returns true iff the file exists.
                
@@ -253,6 +258,12 @@ inline const std::string& File::path() const
        return getPathImpl();
 }
 
+#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
+inline const std::wstring& File::wpath() const
+{
+       return getPathWImpl();
+}
+#endif
 
 inline bool File::operator == (const File& file) const
 {
index 26f63f0..9530c57 100644 (file)
@@ -58,6 +58,7 @@ protected:
        void swapImpl(FileImpl& file);
        void setPathImpl(const std::string& path);
        const std::string& getPathImpl() const;
+       const std::wstring& getPathWImpl() const;
        bool existsImpl() const;
        bool canReadImpl() const;
        bool canWriteImpl() const;
@@ -98,6 +99,10 @@ inline const std::string& FileImpl::getPathImpl() const
        return _path;
 }
 
+inline const std::wstring& FileImpl::getPathWImpl() const
+{
+       return _upath;
+}
 
 } // namespace Poco
 
index 8f2d9a2..cc11165 100644 (file)
@@ -95,9 +95,7 @@ SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessM
        }
 
 #if defined (POCO_WIN32_UTF8)
-       std::wstring utf16name;
-       UnicodeConverter::toUTF16(_name, utf16name);
-       _fileHandle = CreateFileW(utf16name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+       _fileHandle = CreateFileW(file.wpath().c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 #else
        _fileHandle = CreateFileA(_name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 #endif