Skip to content

Commit e56f853

Browse files
obdevhnwyllmm
andcommitted
delete to_cstring
Co-authored-by: hnwyllmm <hnwyllmm@users.noreply.github.com>
1 parent e4ef5c0 commit e56f853

37 files changed

Lines changed: 741 additions & 367 deletions

deps/oblib/src/lib/utility/ob_print_utils.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -367,29 +367,18 @@ int64_t to_string<bool>(const bool &v, char *buffer, const int64_t buffer_size)
367367
return pos;
368368
}
369369

370-
template <>
371-
const char *to_cstring<const char *>(const char *const &str)
372-
{
373-
return str;
374-
}
375-
376-
template <>
377-
const char *to_cstring<int64_t>(const int64_t &v)
378-
{
379-
return to_cstring<int64_t>(v, BoolType<false>());
380-
}
381370
////////////////////////////////////////////////////////////////
382371

383-
const int64_t ObCStringHelperV2::EXPAND_BUF_LEN;
384-
const int64_t ObCStringHelperV2::HELPER_MEMORY_LIMIT;
372+
const int64_t ObCStringHelper::EXPAND_BUF_LEN;
373+
const int64_t ObCStringHelper::HELPER_MEMORY_LIMIT;
385374

386375
ERRSIM_POINT_DEF(EN_CSTRING_HELPER_FORCE_MALLOC);
387-
bool ObCStringHelperV2::is_force_alloc()
376+
bool ObCStringHelper::is_force_alloc()
388377
{
389378
return EN_CSTRING_HELPER_FORCE_MALLOC;
390379
}
391380

392-
void ObCStringHelperV2::force_alloc()
381+
void ObCStringHelper::force_alloc()
393382
{
394383
buf_ = reinterpret_cast<char *>(allocator_.alloc(buf_len_));
395384
if (nullptr == buf_) {

deps/oblib/src/lib/utility/ob_print_utils.h

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,6 @@ const char *to_cstring(const T &obj)
303303
return to_cstring(obj, BoolType<HAS_MEMBER(T, to_cstring)>());
304304
}
305305

306-
template <>
307-
const char *to_cstring<const char *>(const char *const &str);
308-
template <>
309-
const char *to_cstring<int64_t>(const int64_t &v);
310-
311306
template <typename T>
312307
const char *to_cstring(T *obj)
313308
{
@@ -424,12 +419,12 @@ int databuff_print_multi_objs(char* buf, const int64_t buf_len, int64_t &pos, co
424419
ObCStringHelper: convert the object to cstring with an inner buffer
425420
If you need a persistent cstring, you cannot use this class.
426421
*/
427-
class ObCStringHelperV2
422+
class ObCStringHelper
428423
{
429424
const static int64_t EXPAND_BUF_LEN = 16L << 10;
430425
const static int64_t HELPER_MEMORY_LIMIT = 64L << 20;
431426
public:
432-
ObCStringHelperV2()
427+
ObCStringHelper()
433428
: allocator_(SET_USE_500("CStringHelper"))
434429
{
435430
#ifdef ENABLE_DEBUG_LOG
@@ -513,7 +508,7 @@ class ObCStringHelperV2
513508
void force_alloc();
514509

515510
private:
516-
DISABLE_COPY_ASSIGN(ObCStringHelperV2);
511+
DISABLE_COPY_ASSIGN(ObCStringHelper);
517512
private:
518513
ObArenaAllocator allocator_;
519514
char reserve_buf_[1024];
@@ -523,25 +518,6 @@ class ObCStringHelperV2
523518
int ob_errno_ = OB_SUCCESS;
524519
};
525520

526-
class ObCStringHelper
527-
{
528-
public:
529-
template<typename T>
530-
const char *convert(const T &obj)
531-
{
532-
return to_cstring(obj);
533-
}
534-
template<typename T>
535-
int convert(const T &obj, const char *&str)
536-
{
537-
str = to_cstring(obj);
538-
return NULL == str ? OB_ERROR : OB_SUCCESS;
539-
}
540-
void reset()
541-
{
542-
}
543-
};
544-
545521
/// @return OB_SUCCESS or OB_ALLOCATE_MEMORY_FAILED
546522
int multiple_extend_buf(char *&stmt_buf, int64_t &stmt_buf_len, common::ObIAllocator &alloc);
547523
/// @return OB_SUCCESS or OB_SIZE_OVERFLOW

0 commit comments

Comments
 (0)