浏览代码

2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Return const reference.
	* src/DownloadHandlerConstants.cc
	* src/DownloadHandlerConstants.h
	(getMetalinkExtensions)
	(getMetalinkContentTypes)
	(getBtExtensions)
	(getBtContentTypes)
Tatsuhiro Tsujikawa 17 年之前
父节点
当前提交
e59f4f2fe3
共有 3 个文件被更改,包括 34 次插入16 次删除
  1. 10 0
      ChangeLog
  2. 20 12
      src/DownloadHandlerConstants.cc
  3. 4 4
      src/DownloadHandlerConstants.h

+ 10 - 0
ChangeLog

@@ -1,3 +1,13 @@
+2008-05-18  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Return const reference.
+	* src/DownloadHandlerConstants.cc
+	* src/DownloadHandlerConstants.h
+	(getMetalinkExtensions)
+	(getMetalinkContentTypes)
+	(getBtExtensions)
+	(getBtContentTypes)
+	
 2008-05-18  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	* src/HttpHeader.cc (get): Rewritten.

+ 20 - 12
src/DownloadHandlerConstants.cc

@@ -49,28 +49,36 @@ const char* DownloadHandlerConstants::BT_CONTENT_TYPES[] = {
   "application/x-bittorrent"
 };
 
-std::deque<std::string> DownloadHandlerConstants::getMetalinkExtensions()
+const std::deque<std::string>& DownloadHandlerConstants::getMetalinkExtensions()
 {
-  return std::deque<std::string>(&METALINK_EXTENSIONS[0],
-				 &METALINK_EXTENSIONS[arrayLength(METALINK_EXTENSIONS)]);
+  static const std::deque<std::string> l
+    (&METALINK_EXTENSIONS[0],
+     &METALINK_EXTENSIONS[arrayLength(METALINK_EXTENSIONS)]);
+  return l;
 }
 
-std::deque<std::string> DownloadHandlerConstants::getMetalinkContentTypes()
+const std::deque<std::string>& DownloadHandlerConstants::getMetalinkContentTypes()
 {
-  return std::deque<std::string>(&METALINK_CONTENT_TYPES[0],
-				 &METALINK_CONTENT_TYPES[arrayLength(METALINK_CONTENT_TYPES)]);
+  static const std::deque<std::string> l
+    (&METALINK_CONTENT_TYPES[0],
+     &METALINK_CONTENT_TYPES[arrayLength(METALINK_CONTENT_TYPES)]);
+  return l;
 }
 
-std::deque<std::string> DownloadHandlerConstants::getBtExtensions()
+const std::deque<std::string>& DownloadHandlerConstants::getBtExtensions()
 {
-  return std::deque<std::string>(&BT_EXTENSIONS[0],
-				 &BT_EXTENSIONS[arrayLength(BT_EXTENSIONS)]);
+  static const std::deque<std::string> l
+    (&BT_EXTENSIONS[0],
+     &BT_EXTENSIONS[arrayLength(BT_EXTENSIONS)]);
+  return l;
 }
 
-std::deque<std::string> DownloadHandlerConstants::getBtContentTypes()
+const std::deque<std::string>& DownloadHandlerConstants::getBtContentTypes()
 {
-  return std::deque<std::string>(&BT_CONTENT_TYPES[0],
-				 &BT_CONTENT_TYPES[arrayLength(BT_CONTENT_TYPES)]);
+  static const std::deque<std::string> l
+    (&BT_CONTENT_TYPES[0],
+     &BT_CONTENT_TYPES[arrayLength(BT_CONTENT_TYPES)]);
+  return l;
 }
 
 } // namespace aria2

+ 4 - 4
src/DownloadHandlerConstants.h

@@ -46,19 +46,19 @@ class DownloadHandlerConstants
 public:
   static const char* METALINK_EXTENSIONS[];
 
-  static std::deque<std::string> getMetalinkExtensions();
+  static const std::deque<std::string>& getMetalinkExtensions();
 
   static const char* METALINK_CONTENT_TYPES[];
 
-  static std::deque<std::string> getMetalinkContentTypes();
+  static const std::deque<std::string>& getMetalinkContentTypes();
 
   static const char* BT_EXTENSIONS[];
 
-  static std::deque<std::string> getBtExtensions();
+  static const std::deque<std::string>& getBtExtensions();
 
   static const char* BT_CONTENT_TYPES[];
 
-  static std::deque<std::string> getBtContentTypes();
+  static const std::deque<std::string>& getBtContentTypes();
 };
 
 } // namespace aria2