Skip to content

Commit 4416368

Browse files
committed
Now using Highs_getHighsLpColOrRowName in Highs_getRowName and Highs_getColName
1 parent 05a0625 commit 4416368

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

highs/interfaces/highs_c_api.cpp

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,11 +1066,20 @@ HighsInt Highs_getRowsByMask(const void* highs, const HighsInt* mask,
10661066
return (HighsInt)status;
10671067
}
10681068

1069-
HighsInt Highs_getRowName(const void* highs, const HighsInt row, char* name) {
1069+
static HighsInt Highs_getHighsLpColOrRowName(const void* highs,
1070+
const HighsLp& lp,
1071+
const bool is_col,
1072+
const HighsInt index,
1073+
char* name) {
10701074
std::string name_v;
1071-
HighsInt retcode = (HighsInt)((Highs*)highs)->getRowName(row, name_v);
1075+
HighsStatus status = ((Highs*)highs)->getColOrRowName(lp, is_col, index, name_v);
1076+
if (status == HighsStatus::kError) return kHighsStatusError;
10721077
strcpy(name, name_v.c_str());
1073-
return retcode;
1078+
return kHighsStatusOk;
1079+
}
1080+
1081+
HighsInt Highs_getRowName(const void* highs, const HighsInt row, char* name) {
1082+
return Highs_getHighsLpColOrRowName(highs, ((Highs*)highs)->getLp(), false, row, name);
10741083
}
10751084

10761085
HighsInt Highs_getRowByName(const void* highs, const char* name,
@@ -1082,10 +1091,7 @@ HighsInt Highs_getRowByName(const void* highs, const char* name,
10821091
}
10831092

10841093
HighsInt Highs_getColName(const void* highs, const HighsInt col, char* name) {
1085-
std::string name_v;
1086-
HighsInt retcode = (HighsInt)((Highs*)highs)->getColName(col, name_v);
1087-
strcpy(name, name_v.c_str());
1088-
return retcode;
1094+
return Highs_getHighsLpColOrRowName(highs, ((Highs*)highs)->getLp(), true, col, name);
10891095
}
10901096

10911097
HighsInt Highs_getColByName(const void* highs, const char* name,
@@ -1327,18 +1333,6 @@ HighsInt Highs_getPresolvedLp(const void* highs, const HighsInt a_format,
13271333
a_start, a_index, a_value, integrality);
13281334
}
13291335

1330-
static HighsInt Highs_getHighsLpColOrRowName(const void* highs,
1331-
const HighsLp& lp,
1332-
const bool is_col,
1333-
const HighsInt index,
1334-
char* name) {
1335-
std::string name_v;
1336-
HighsStatus status = ((Highs*)highs)->getColOrRowName(lp, is_col, index, name_v);
1337-
if (status == HighsStatus::kError) return kHighsStatusError;
1338-
strcpy(name, name_v.c_str());
1339-
return kHighsStatusOk;
1340-
}
1341-
13421336
HighsInt Highs_getPresolvedColName(const void* highs, const HighsInt col, char* name) {
13431337
return Highs_getHighsLpColOrRowName(highs, ((Highs*)highs)->getPresolvedLp(), true, col, name);
13441338
}

0 commit comments

Comments
 (0)