Navigation Menu

Skip to content

Commit

Permalink
path mapper: momoize result
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Mar 19, 2012
1 parent e6e0279 commit 27af014
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/mrn_path_mapper.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -30,6 +30,8 @@
namespace mrn {
PathMapper::PathMapper(const char *mysql_path)
: mysql_path_(mysql_path) {
db_path_[0] = '\0';
db_name_[0] = '\0';
}

/**
Expand All @@ -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_);
Expand All @@ -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_);
Expand Down

0 comments on commit 27af014

Please sign in to comment.