[Groonga-mysql-commit] mroonga/mroonga [fix-for-visual-studio] path mapper: momoize result

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Oct 4 11:03:51 JST 2012


Kouhei Sutou	2012-03-19 18:13:27 +0900 (Mon, 19 Mar 2012)

  New Revision: 27af014a319779f3cd17a115606fe10ffe0e1c78
  https://github.com/mroonga/mroonga/commit/27af014a319779f3cd17a115606fe10ffe0e1c78

  Log:
    path mapper: momoize result

  Modified files:
    lib/mrn_path_mapper.cpp

  Modified: lib/mrn_path_mapper.cpp (+11 -1)
===================================================================
--- lib/mrn_path_mapper.cpp    2012-03-19 18:08:55 +0900 (2e2eb2b)
+++ lib/mrn_path_mapper.cpp    2012-03-19 18:13:27 +0900 (f059b7f)
@@ -2,7 +2,7 @@
 /*
   Copyright(C) 2010 Tetsuro IKEDA
   Copyright(C) 2011-2012 Kentoku SHIBA
-  Copyright(C) 2011 Kouhei Sutou <kou �� clear-code.com>
+  Copyright(C) 2011-2012 Kouhei Sutou <kou �� clear-code.com>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,8 @@
 namespace mrn {
   PathMapper::PathMapper(const char *mysql_path)
     : mysql_path_(mysql_path) {
+    db_path_[0] = '\0';
+    db_name_[0] = '\0';
   }
 
   /**
@@ -39,6 +41,10 @@ namespace mrn {
    *   "/tmp/mysql-test/var/tmp/mysqld.1/#sql27c5_1_0.mrn"
    */
   const char *PathMapper::db_path() {
+    if (db_path_[0] != '\0') {
+      return db_path_;
+    }
+
     if (strncmp(mysql_path_, "./", 2) == 0) {
       int i = 2, j = 0, len;
       len = strlen(mysql_path_);
@@ -60,6 +66,10 @@ namespace mrn {
    *   "/tmp/mysql-test/var/tmp/mysqld.1/#sql27c5_1_0"
    */
   const char *PathMapper::db_name() {
+    if (db_name_[0] != '\0') {
+      return db_name_;
+    }
+
     if (strncmp(mysql_path_, "./", 2) == 0) {
       int i = 2, j = 0, len;
       len = strlen(mysql_path_);
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-mysql-commit mailing list
Back to archive index