restructued solution and improved string
This commit is contained in:
parent
4f9b04c049
commit
5bbed99591
12 changed files with 28 additions and 26 deletions
|
@ -1,9 +1,9 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31624.102
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.1778
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LSString", "LSString\LSString.vcxproj", "{5FE98B77-3558-4384-BDAF-82AC8B69B752}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LSFramework", "LSFramework\LSFramework.vcxproj", "{5FE98B77-3558-4384-BDAF-82AC8B69B752}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
@ -23,33 +23,33 @@
|
|||
<ProjectGuid>{5FE98B77-3558-4384-BDAF-82AC8B69B752}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>String</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>LSString</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>LSFramework</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
|
@ -6,11 +6,9 @@ LSString::LSString(const char* pData)
|
|||
: m_uiLength(StringLength(pData))
|
||||
, m_uiCapacity(StringLength(pData))
|
||||
{
|
||||
if (!pData) return;
|
||||
|
||||
m_pData = new char[m_uiLength + 1];
|
||||
memset(m_pData, 0, m_uiLength + 1);
|
||||
memcpy(m_pData, pData, m_uiLength);
|
||||
if(pData) memcpy(m_pData, pData, m_uiLength);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -54,21 +52,21 @@ void LSString::Insert(const char* pData, size_t uiPos)
|
|||
{
|
||||
if (!pData) return;
|
||||
|
||||
size_t uilength = StringLength(pData);
|
||||
size_t uiNewLength = m_uiLength + uilength;
|
||||
size_t zLength = StringLength(pData);
|
||||
size_t zNewLength = m_uiLength + zLength;
|
||||
|
||||
while (uiNewLength > m_uiCapacity)
|
||||
while (zNewLength > m_uiCapacity)
|
||||
{
|
||||
IncreaseCapacity(uiNewLength);
|
||||
IncreaseCapacity(zNewLength);
|
||||
}
|
||||
|
||||
char* pLeft = m_pData + uiPos;
|
||||
char* pRight = m_pData + uiPos + uilength;
|
||||
char* pRight = m_pData + uiPos + zLength;
|
||||
|
||||
memcpy(pRight, m_pData + uiPos, m_uiLength - uiPos);
|
||||
memcpy(pLeft, pData, uilength);
|
||||
memcpy(pLeft, pData, zLength);
|
||||
|
||||
m_uiLength = uiNewLength;
|
||||
m_uiLength = zNewLength;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -86,7 +84,7 @@ void LSString::Append(const std::string& sRhs)
|
|||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
void LSString::Append(const char* pData)
|
||||
{
|
||||
Insert(pData, StringLength(pData));
|
||||
Insert(pData, m_uiLength);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
|
@ -16,5 +16,6 @@ Timer::~Timer()
|
|||
auto end = std::chrono::time_point_cast<std::chrono::microseconds>(endTimePoint).time_since_epoch().count();
|
||||
|
||||
auto duration = end - start;
|
||||
std::cout << "Duration in Microseconds: " << duration << " (" << duration * 0.001 << " ms)" << std::endl;
|
||||
printf("Duration in Microseconds: %2d (%.3f ms)\n", duration, (duration * 0.001));
|
||||
//std::cout << "Duration in Microseconds: " << duration << " (" << duration * 0.001 << " ms)" << std::endl;
|
||||
}
|
|
@ -4,21 +4,21 @@
|
|||
#include "Timer.h"
|
||||
|
||||
#define RUNS 50U
|
||||
#define PAYLOAD "187"
|
||||
#define PAYLOAD "1873612578869"
|
||||
|
||||
int main()
|
||||
{
|
||||
// - STRING
|
||||
{
|
||||
printf("LSString:\n");
|
||||
printf("Number of runs: %d:\n", (int)RUNS);
|
||||
printf("---LSString---\n");
|
||||
printf("Number of runs: %d\n", (int)RUNS);
|
||||
Timer ttt;
|
||||
for (size_t zRun = 1; zRun <= RUNS; zRun++)
|
||||
{
|
||||
printf("Run: %2d: ", (int)zRun);
|
||||
printf("Run: %2d: ", static_cast<int>(zRun));
|
||||
|
||||
Timer tt;
|
||||
LSString s("361");
|
||||
LSString s(nullptr);
|
||||
|
||||
for (size_t z = 0; z < RUNS * 187; z++)
|
||||
{
|
||||
|
@ -29,6 +29,9 @@ int main()
|
|||
|
||||
// - LIST
|
||||
{
|
||||
printf("---LSList---\n");
|
||||
printf("Number of runs: %d\n", (int) RUNS);
|
||||
Timer ttt;
|
||||
int i1 = 1187;
|
||||
int i2 = 2361;
|
||||
int i3 = 3257;
|
Loading…
Add table
Add a link
Reference in a new issue