<commit_before>// @(#)root/base:$Name:  $:$Id: String.cxx,v 1.18 2002/12/05 15:31:03 rdm Exp $
// Author: <NAME> 03/09/2003

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME>, <NAME> and al.           *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// std::string helper utilities                                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include <string>
#include "TBuffer.h"
#include "TString.h"

namespace std {} using namespace std;

void std_string_streamer(TBuffer &b, void *objadd) 
{
   // Streamer function for std::string object.

   string *obj = (string*)objadd;
   
   if (b.IsReading()) {

      TString helper;
      helper.Streamer(b);
      (*obj) = helper.Data();
      
   } else {

      TString helper( obj ? obj->c_str() : "" );
      helper.Streamer(b);

   }

}


// Declare the streamer to the string TClass object
RootStreamer(string,std_string_streamer);

// Set a version number of the string TClass object
RootClassVersion(string,2);

<commit_msg>From Markus:   Do not use TString helper for streaming of std::string.   Native implementation is 60 % faster for small strings.<commit_after>// @(#)root/base:$Name:  $:$Id: String.cxx,v 1.1 2004/01/10 10:52:29 brun Exp $
// Author: <NAME> 03/09/2003

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME>, <NAME> and al.           *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// std::string helper utilities                                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include <string>
#include "TBuffer.h"
#include "TString.h"

namespace std {} using namespace std;

void std_string_streamer(TBuffer &b, void *objadd) 
{
   // Streamer function for std::string object.
   string *obj = (string*)objadd;
   Int_t   nbig;
   UChar_t nwh;
   if (b.IsReading()) {
      b >> nwh;
      if (nwh == 255)  {
         b >> nbig;
         obj->resize(nbig,'\0');
         b.ReadFastArray((char*)obj->data(),nbig);
      }
      else  {
         obj->resize(nwh,'\0');
         b.ReadFastArray((char*)obj->data(),nwh);
      }
   } else if ( obj ) {
      nbig = obj->length();
      if (nbig > 254) {
         nwh = 255;
         b << nwh;
         b << nbig;
      } else {
         nwh = UChar_t(nbig);
         b << nwh;
      }
      b.WriteFastArray(obj->data(),nbig);
   }
}

// Declare the streamer to the string TClass object
RootStreamer(string,std_string_streamer);

// Set a version number of the string TClass object
RootClassVersion(string,2);


{'fraction_non_alphanumeric': 0.25853400370468377, 'fraction_numerical': 0.021169621593014026, 'mean_word_length': 1.2473246135552913, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4469012', 'n_tokens_mistral': 990, 'n_tokens_neox': 893, 'n_words': 231}